Quickstart: Create and query an Azure Analysis Services model
This quickstart guides you through the process of creating an Azure Analysis Services instance, connecting to it with Visual Studio, and deploying a sample tabular model. You'll then query the model using SQL Server Management Studio (SSMS).
Step 1: Create an Azure Analysis Services instance
Before you can create a model, you need an Azure Analysis Services server instance. You can create one from the Azure portal.
- In the Azure portal, click Create a resource.
- Search for Analysis Services and select it.
- Click Create.
- Fill in the required details: Subscription, Resource Group, Server name, Location, and Pricing tier.
- Click Review + create, then Create.
Step 2: Connect to the server with Visual Studio
You'll use Visual Studio with the Analysis Services projects extension to create and deploy tabular models.
- Install Visual Studio (Community edition is sufficient).
- Install the Analysis Services Projects extension from the Visual Studio Marketplace.
- In Visual Studio, create a new project: File > New > Project.
- Search for Tabular Project and select it.
- Give your project a name and location, then click Create.
- In the Model options dialog, select Connect to existing and enter your Analysis Services server name created in Step 1. Choose DirectQuery for the Compatibility level.
- Click Create.
Step 3: Deploy a sample tabular model
For this quickstart, we'll deploy a pre-built sample model. You can download the SQL Server samples, which includes the AdventureWorksDW sample database.
- Once connected in Visual Studio, right-click on your project in Solution Explorer and select Add > Existing Project as Tabular Model.
- Browse to and select the
AdventureWorksDW2019.abf
file from the downloaded samples. - Right-click on your project in Solution Explorer and select Deploy.
- In the deployment dialog, ensure your Analysis Services server is selected and click Deploy.
Step 4: Query the model with SQL Server Management Studio (SSMS)
Now, let's query the deployed model using SSMS.
- Download and install SQL Server Management Studio (SSMS).
- Open SSMS and connect to your Analysis Services server instance using the server name from Step 1.
- Right-click on the database (which will be the name of your deployed model, e.g.,
AdventureWorksDW2019
) and select New Query > MDX. - Enter a simple MDX query, for example:
SELECT {[Measures].[Sales Amount]} ON COLUMNS, {[Dim Customer].[Country].[Country].MEMBERS} ON ROWS FROM [AdventureWorksDW2019]
- Click Execute. You should see sales amounts by country.
Tip: For more complex modeling and DAX queries, explore the full documentation and tutorials available for Azure Analysis Services.