Microsoft Learn

Deploying SSAS Models

This tutorial guides you through the process of deploying a SQL Server Analysis Services (SSAS) model to a production or staging environment. Deployment is a critical step in making your BI solutions accessible to end-users. We will cover various methods, including using Visual Studio, SQL Server Management Studio (SSMS), and scripting.

Prerequisites

  • SQL Server Analysis Services (SSAS) installed and configured.
  • A developed SSAS Tabular or Multidimensional model.
  • Visual Studio with Analysis Services projects extension installed.
  • SQL Server Management Studio (SSMS) installed.
  • Appropriate permissions to deploy to the target SSAS instance.

Deployment Methods

There are several common ways to deploy your SSAS models:

  1. Using Visual Studio: The most integrated approach during development.
  2. Using SQL Server Management Studio (SSMS): A GUI-based method for managing and deploying models.
  3. Using Scripting (AMO/TOM): For automated and programmatic deployments.

Method 1: Deployment from Visual Studio

When you finish developing your model in Visual Studio, you can deploy it directly to an SSAS server.

Step 1: Set Deployment Properties

In Visual Studio, right-click on your SSAS project in Solution Explorer and select Properties.

Navigate to the Deployment tab. Here, you will configure:

  • Server Name: The name or IP address of your SSAS instance (e.g., YourServerName or YourServerName\InstanceName).
  • Database Name: The name of the database to be created or updated on the SSAS server.

Ensure the correct configuration (Debug or Release) is selected in the dropdown at the top of the Properties window.

Step 2: Deploy the Project

Right-click on your SSAS project in Solution Explorer again and select Deploy.

Visual Studio will build the project and then initiate the deployment process. You can monitor the progress in the Show Output from: Build window.

If successful, your model will be available on the specified SSAS server.

Method 2: Deployment using SQL Server Management Studio (SSMS)

SSMS provides a robust interface for managing SSAS databases, including deploying existing model files (.asdatabase).

Step 1: Connect to SSAS Server

Open SSMS and connect to your SSAS instance.

Step 2: Deploy Database

Right-click on the Databases folder in Object Explorer and select Restore.

Alternatively, you can use the Import/Export Data wizard or deploy a project file (.asproj) if you are starting a new deployment from a project.

For deploying a pre-built database from a Visual Studio deployment artifact:

  1. Right-click the Databases folder and choose New Database....
  2. In the New Database dialog, enter the desired Database name.
  3. Click OK.
  4. Right-click the newly created database and select Process... if you need to populate it, or simply ensure its structure is correct.
  5. If you have a .asdatabase file generated by Visual Studio, you can right-click the Databases folder and select Restore, then specify the backup file.

Method 3: Deployment using Scripting (AMO/TOM)

For automated deployments, especially in CI/CD pipelines, using Analysis Management Objects (AMO) or Tabular Object Model (TOM) is recommended.

Here's a conceptual C# example using TOM:


using Microsoft.AnalysisServices.Tabular;
using System;

public class DeploySSAS
{
    public static void DeployModel(string serverName, string databaseName, string modelFilePath)
    {
        try
        {
            Server server = new Server();
            server.Connect($"Provider=MSOLAP;Data Source={serverName}");

            Database database = server.Databases.FindByName(databaseName);
            if (database == null)
            {
                database = new Database();
                database.Name = databaseName;
                server.Databases.Add(database);
                database.Update();
            }

            // Load the model from file
            database.Model.Deserialize(System.IO.File.ReadAllBytes(modelFilePath));
            database.Model.SaveChanges();

            Console.WriteLine($"Model deployed successfully to {serverName}\\{databaseName}");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error deploying model: {ex.Message}");
        }
    }

    public static void Main(string[] args)
    {
        // Example usage:
        // DeployModel("YourSSASServer", "YourDatabase", @"C:\Path\To\Your\Model.asdatabase");
    }
}
                

This script demonstrates connecting to the server, finding or creating a database, and deserializing a model file. You would typically use this within a more complex application or a build script.

Post-Deployment Tasks

  • Processing the Model: After deployment, you often need to process the tables and partitions to load data from your data sources.
  • Security Configuration: Assign roles and permissions to users and groups.
  • Testing: Verify that the deployed model functions as expected and that users can access it correctly.

Troubleshooting Common Issues

  • Connection Errors: Ensure the server name and credentials are correct, and that firewalls are not blocking access.
  • Permissions: Verify that the account performing the deployment has sufficient administrative rights on the SSAS server.
  • Model Compatibility: Ensure the SSAS server version supports the compatibility level of the deployed model.