简体   繁体   English

用于Azure SSAS多维数据集更新的Rest API

[英]Rest API for Azure SSAS cube refreshment

I'm currently trying to create a Rest API to refresh a SSAS cube in Azure. 我目前正在尝试创建Rest API来刷新Azure中的SSAS多维数据集。 I followed all the steps from this link . 我遵循了此链接中的所有步骤。 Then I'm using that code to refresh the Cube1 : 然后,我使用该代码刷新Cube1:

#r "Microsoft.AnalysisServices.Tabular.DLL"
#r "Microsoft.AnalysisServices.Core.DLL"
#r "System.Configuration"

using System; 
using System.Security; 
using System.Security.Principal; 
using System.Configuration; 
using Microsoft.AnalysisServices.Tabular;

public static void Run(TimerInfo myTimer, TraceWriter log) 
{
    log.Info($"C# Timer trigger function started at: DateTime.Now}");    
    // try  
    // {
    Microsoft.AnalysisServices.Tabular.Server asSrv = new Microsoft.AnalysisServices.Tabular.Server();

    log.Info("Log1");

    var connStr = "Provider=MSOLAP;Data Source=asazure://serveraddress; Initial Catalog=Cube1;User ID=*****;Password=*****"; 
    log.Info("Log2");

    asSrv.Connect(connStr);        

    log.Info("Log3");   

    Database db = asSrv.Databases["Cube1"]; 
    log.Info("Log4");

    Model m = db.Model; 
    m.RequestRefresh(RefreshType.Full);     // Mark the model for refresh
    db.Model.SaveChanges();     //commit  which will execute the refresh
    asSrv.Disconnect();
    // }
    // catch (Exception e)
    // {
    //     log.Info($"C# Timer trigger function exception: {e.ToString()}");
    // }

    log.Info($"C# Timer trigger function finished at: {DateTime.Now}"); 
}

Normally everything should be ok but here is my error message : 通常,一切都应该没问题,但这是我的错误消息:

Could not load type 'System.Security.Principal.WindowsImpersonationContext' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=***** 无法从程序集'mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = *****加载类型'System.Security.Principal.WindowsImpersonationContext'

Any idea to solve this ? 有解决的办法吗?

Thanks a lot. 非常感谢。

好像您缺少对nuget包System.Security.Principal的引用

#r "System.Security.Principal"

Please note that there is REST API available for Azure Analysis Services. 请注意,存在适用于Azure Analysis Services的REST API。

You can find it here https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-async-refresh 您可以在这里找到它https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-async-refresh

To use it just 只是使用它

  1. Create Azure AD Service Principal (Application) 创建Azure AD服务主体(应用程序)
  2. Add it as admin to the server 将其作为管理员添加到服务器
  3. Get token for this service principal for resource https://*.asazure.windows.net 获取资源https://*.asazure.windows.net的此服务主体的令牌
  4. Send POST request to 发送POST请求至

    https:// rollout .asazure.windows.net/servers/ serverName /models/ resource /refresh https://首次展示 .asazure.windows.net / servers / serverName / models / resource / refresh

with body 与身体

{
  "Type": "Full",
  "CommitMode": "transactional",
  "MaxParallelism": 2,
  "RetryCount": 2,
  "Objects": [
    {
        "table": "DimCustomer",
        "partition": "DimCustomer"
    },
    {
        "table": "DimDate"
    }
  ]
}

For detailed description check 有关详细说明,请检查

https://marczak.io/posts/2019/06/logic-apps-refresh-analysis-services/ https://marczak.io/posts/2019/06/logic-apps-refresh-analysis-services/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM