【问题标题】:How to connect from .NET .dll file to Azure using Linked Service如何使用链接服务从 .NET .dll 文件连接到 Azure
【发布时间】:2018-02-07 03:42:22
【问题描述】:

我想在 Visual Studio 中编写类似于此链接 (https://azure.microsoft.com/en-us/blog/automating-azure-analysis-services-processing-with-azure-functions/) 底部的代码并构建 DLL 文件的代码。但是,我不想使用连接字符串,而是想使用 Azure 门户中的现有链接服务。

我们的目标是创建一个刷新我的多维数据集的 DLL,同时使用我的 Azure 门户中已有的现有链接服务。

这可能吗?

谢谢。

#r "Microsoft.AnalysisServices.Tabular.DLL"

#r "Microsoft.AnalysisServices.Core.DLL"

#r "System.Configuration"

using System;

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();

                var connStr = ConfigurationManager.ConnectionStrings["AzureASConnString"].ConnectionString; // Change this to a Linked Service connection

                asSrv.Connect(connStr);

                Database db = asSrv.Databases["AWInternetSales2"];

                Model m = db.Model;

                db.Model.RequestRefresh(RefreshType.Full);     // Mark the model for refresh

                //m.RequestRefresh(RefreshType.Full);     // Mark the model for refresh

                m.Tables["Date"].RequestRefresh(RefreshType.Full);     // Mark only one table 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}"); 

}    

【问题讨论】:

    标签: c# .net azure azure-analysis-services


    【解决方案1】:

    所以我猜您正在使用数据工厂,并且您想从您的管道中处理您的分析服务模型。我看不出您的问题与数据湖存储实际上有什么关系。

    要从数据工厂(仅限 v2)触发 Azure Functions,您必须使用 Web 活动。可以将链接服务作为有效负载的一部分传递,如documentation 所示。它看起来像这样:

    {
    "body": {
        "myMessage": "Sample",
        "linkedServices": [{
            "name": "MyService1",
            "properties": {
                ...
            }
        }]
    }
    

    但是,数据工厂中没有分析服务链接服务,至少,我没有听说过这样的事情。然而,从管道传递连接字符串似乎是个好主意。您可以将它作为pipeline parameter 在您的网络请求正文中传递。

    在您的管道中创建一个参数

    将其添加到您的网络活动负载中

    {
        "body": {
                "AzureASConnString": "@pipeline().parameters.AzureASConnString"
    }
    

    您可以从 here 中描述的函数中检索此值

    【讨论】:

    • 对,我应该提一下,我不会像在提供的链接中那样在 Portal 中编写代码,而是将代码作为 .DLL 文件放在 Visual Studio 中。所以我想知道是否有办法在我的代码中使用 Azure 中现有的链接服务而不是连接字符串。
    • 啊,看来我误解了你的问题。您能否更新您的问题,因为您不是在谈论数据湖,而是在谈论 Azure 分析服务。此外,链接服务是在数据工厂中使用的概念,而不是在 Azure 函数中使用的概念。如果您可以添加您正在谈论的“Azure 中的链接服务”的屏幕截图,这将有所帮助。
    猜你喜欢
    • 1970-01-01
    • 2021-07-28
    • 1970-01-01
    • 2021-01-24
    • 2013-07-08
    • 2016-11-30
    • 2012-04-19
    • 1970-01-01
    • 2020-02-18
    相关资源
    最近更新 更多