未加星标

Automating Azure Analysis Services processing with Azure Functions

字体大小 | |
[系统(windows) 所属分类 系统(windows) | 发布者 店小二03 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

In this post, we’ll walk through a simple example on how you can setup Azure Functions to process Azure Analysis Services tables.

Azure functions are perfect for running small pieces of code in the cloud. To learn more about Azure Functions, see Azure Functions Overview and Azure Functions pricing .

Create an Azure Function

To get started, we first need to create an Azure Function

1. Go to the portal and create a new Function App .

2. Type a unique Name for your new function app, choose the Resource Group and Location . For the Hosting plan use App Service Plan .

Note : As the duration of processing Analysis Services tables and models may vary, use a Basic or Standard App Service Plan and make sure that the Always On setting is turned on, otherwise the Function may time out if the processing takes longer.

Click Create to deploy the Function App .

3. In the Quickstart tab, click Timer and C# , and then click Create this function .


Automating Azure Analysis Services processing with Azure Functions
Configure timer settings

Now that we’ve created our new function, we need to configure some settings. First, let’s configure a schedule.

1. Go to the Integrate > Timer > S chedule.

The default schedule has a CRON expression for every 5 minutes.

Change this to any setting you would like. In the example below I used an expression to trigger the function at 3AM every day. Click Documentation to see a description and some examples for CRON expressions.


Automating Azure Analysis Services processing with Azure Functions

2. Click Save .

Configure application settings

Before we begin writing our code, we need to configure the application.

Important: Make sure you have the latest data providers installed on your computers. To get more info and download, see Data providers for connecting to Azure Analysis Services .

After installing the providers, you’ll need these two files in the next step:

C:\Program Files\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.AnalysisServices.Core.dll

C:\Program Files\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.AnalysisServices.Tabular.dll

1. In the new Azure Function, go to Function app settings > Go to Kudu, to open the debug console.


Automating Azure Analysis Services processing with Azure Functions

2. Navigate to the function in D:\home\site\wwwroot\yourfunctionname , and then create a folder named bin .


Automating Azure Analysis Services processing with Azure Functions

3. Navigate to the newly created bin folder, and then drop the two files specified in the previews point. It should look like this:


Automating Azure Analysis Services processing with Azure Functions

4. Refresh your browser. In Develop > bin , you should see the two files in it (If you don’t see the file structure, click View files ).


Automating Azure Analysis Services processing with Azure Functions

5. Before we write our code, we need to create a connection string. In Function app settings , click Configure app settings .


Automating Azure Analysis Services processing with Azure Functions

6. Scroll to the end of the Application settings view, to the Connection strings section, and then create a Custom connection string.

Provider=MSOLAP;Data Source=asazure://region.asazure.windows.net/servername; Initial Catalog=dbname;User [email protected];Password=pw


Automating Azure Analysis Services processing with Azure Functions
Add code

Now that we have our function’s configuration settings in-place, we can enter the code. You’ll need to reference the DLLs we uploaded, but other than that it looks like any other .Net code.

Note: In this example, I included some commented lines to only process a table or the model.

#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;

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

}

Click Save to save the changes, and then click Run to test the code. You’ll get an output window where you will be able to see the log information and exceptions.


Automating Azure Analysis Services processing with Azure Functions

Learn more on Azure Analysis Services andAzure Functions.

本文系统(windows)相关术语:三级网络技术 计算机三级网络技术 网络技术基础 计算机网络技术

主题: C#SQL.NetSQL Server
分页:12
转载请注明
本文标题:Automating Azure Analysis Services processing with Azure Functions
本站链接:http://www.codesec.net/view/532552.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(windows) | 评论(0) | 阅读(54)