Partilhar via


Azure Analysis Services processing/refresh sample AMO code

Sample code to process object in Azure Analysis Services

Visit this web page Data providers for connecting to Azure Analysis Services, URL is /en-us/azure/analysis-services/analysis-services-data-providers

At the bottom of the web page, download then install AMO.

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using Microsoft.AnalysisServices;

using Microsoft.AnalysisServices.Tabular;

namespace AMOAzureASProcess

{

class
Program

{

static
void Main(string[] args)

{

try

{

Microsoft.AnalysisServices.Server s = new Microsoft.AnalysisServices.Server();

 

 

 

s.Connect(@"Password=something;Persist Security Info=True;User ID=someone@microsoft.com;Initial Catalog= MyDatabase;Data Source=asazure://southcentralus.asazure.windows.net/someserver");

 

 

Microsoft.AnalysisServices.Database db = s.Databases["MyDatabase"];

 

//process a table

Model m = db.Model;

m.Tables["DimDate"].RequestRefresh(Microsoft.AnalysisServices.Tabular.RefreshType.Full);

 

 

//process a partition

m.Tables["FactInternetSales"].Partitions["FactInternetSales"].RequestRefresh(Microsoft.AnalysisServices.Tabular.RefreshType.Full);

db.Update(UpdateOptions.ExpandFull);

 

m.RequestRefresh(Microsoft.AnalysisServices.Tabular.RefreshType.Calculate);

db.Update(UpdateOptions.ExpandFull);

 

s.Disconnect();

}

catch (Exception ex)

{

Console.WriteLine(ex.ToString());

}

Console.WriteLine("Process is successful");

Console.ReadLine();

}

}

}