0

I want to write a code, similar to the code at the bottom of this link (https://azure.microsoft.com/en-us/blog/automating-azure-analysis-services-processing-with-azure-functions/) in Visual Studio and building a DLL file. However instead of using the connection string, i would like to use an existing Linked Service from my Azure portal.

The goal is to create a DLL that refreshes my Cube, while at the same time using an existing Linked Service which is already in my Azure Portal.

Is this possible?

Thanks.

#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}"); 

}    
Michael Rys
  • 6,684
  • 15
  • 23

1 Answers1

0

So I guess you're using the Data Factory and you want to process your analysis services model from your pipeline. I don't see what your question actually has to do with the Data lake store.

To trigger Azure Functions from the Data Factory (v2 only), you'll have to use a web activity. It is possible to pass a Linked Service as part of your payload, as shown in the documentation. It looks like this:

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

However, there is no Analysis services linked service in the Data Factory, at least, I didn't hear of such a thing. Passing in a connectionstring from the pipeline seems like a good idea however. You could pass it as a pipeline parameter in your body of the webrequest.

Create a parameter in your pipeline enter image description here

Add it to your Web Activity Payload

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

You can retrieve this value from functions like described here

Simon Zeinstra
  • 795
  • 8
  • 19
  • Right, I should mention that instead of writing my code inside the Portal like in the provided link, I will be putting the code in Visual Studio as a .DLL file. So I'm wondering if there's a way to use an existing Linked Service in Azure inside my code instead of a connection string. – Nabeel Zulkifli Feb 06 '18 at 06:32
  • Ah, it seems I mis-interpreted your question. Could you please update your question, because you're not talking about the Data Lake but about Azure Analysis services. Also, a linked service is a concept that is used in the Data Factory and not in Azure functions. It would help if you can add a screenshot of the "linked service in Azure" that you are talking about. – Simon Zeinstra Feb 06 '18 at 09:40