3

I am attempting to automate partition refreshes in Azure Analysis Services via C#. I have installed and referenced the latest 'Microsoft.AnalysisServices. ..' assemblies found here:

https://learn.microsoft.com/en-us/azure/analysis-services/analysis-services-data-providers.

I then have the following code:

using System; using Microsoft.AnalysisServices.Tabular;

    public void Run()
    {
        Server asSrv = new Server();

        try
        {

            asSrv.Connect(ASConnectionString);
            Database db = asSrv.Databases.FindByName("HospoIQTabular");
            Model m = db.Model;

            // only refresh 2017 partitions

            m.Tables["Sales"].Partitions["Sales - Post 2017"].RequestRefresh(RefreshType.Full);
            m.Tables["Payments"].Partitions["Payments - Post 2017"].RequestRefresh(RefreshType.Full);

            db.Model.SaveChanges();     // commit which will execute the refresh

        }
        catch (Exception e)
        {
            OnEventLog(e.Message);
        }
        finally
        {
            asSrv.Disconnect();
            asSrv = null;
        }

    }

Connect to the server and database itself works fine. However, attempting to reference 'db.Model' throws the following exception:

The value '2' is unexpected for type 'DataSourceType'.

I've looked but can't find any help anywhere on this. Any thoughts??

Justin
  • 9,634
  • 6
  • 35
  • 47
  • 2
    I've figured it out. Need to use the assemblies directly from here: C:\Program Files\Microsoft SQL Server\140\SDK\Assemblies. Not the 130 versions as indicated in some blogs online. – Andrae Gaeth Jun 01 '17 at 03:35
  • your comment helped me, could you post it as answer to this question? – arghtype Sep 08 '17 at 23:05

2 Answers2

2

The problem is similar with the NuGet package Microsoft.AnalysisServices.Tabular (v13)

Fortunately you can use the NuGet packages listed here: https://learn.microsoft.com/en-us/azure/analysis-services/analysis-services-data-providers.

In Visual Studio NuGet lists this package as Microsoft.AnalysisServices.retail.amd64

degathem
  • 5
  • 4
1

For me, the path that worked was C:\Program Files (x86)\Microsoft SQL Server\140\SDK\Assemblies but only after reading Andrae comment which sent me on the right direction

Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
Lior
  • 41
  • 1