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

时间:2018-11-22 08:53:07

标签: c# rest azure ssas azure-analysis-services

我当前正在尝试创建Rest API来刷新Azure中的SSAS多维数据集。我遵循了link中的所有步骤。然后,我使用该代码刷新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}"); 
}

通常情况下一切正常,但这是我的错误消息:

  

无法加载类型   程序集中的“ System.Security.Principal.WindowsImpersonationContext”   'mscorlib,版本= 4.0.0.0,文化=中性,PublicKeyToken = *****

有什么办法解决这个问题吗?

非常感谢。

2 个答案:

答案 0 :(得分:0)

看起来您缺少对nuget软件包System.Security.Principal的引用

#r "System.Security.Principal"

答案 1 :(得分:0)

请注意,有适用于Azure Analysis Services的REST API。

您可以在这里https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-async-refresh

找到它

仅使用

  1. 创建Azure AD服务主体(应用程序)
  2. 将其作为管理员添加到服务器
  3. 获取资源 https://*.asazure.windows.net
  4. 的此服务主体的令牌
  5. 发送POST请求到

    https:// 推出 .asazure.windows.net / servers / 服务器名称 / models / 资源 /刷新

    < / li>

随身

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

有关详细说明,请检查

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