Azure Analysis Services REST API

Introduction to the REST API

The Azure Analysis Services REST API provides a programmatic interface to manage and interact with your Azure Analysis Services models. You can use this API to perform various operations, including deploying models, executing queries, managing data sources, and monitoring operations.

This API supports operations on server, database, and model objects. It's designed to be used with languages and tools that can make HTTP requests, such as PowerShell, C#, Python, or curl.

Authentication and Authorization

All requests to the Azure Analysis Services REST API must be authenticated. The API supports Azure Active Directory (Azure AD) authentication. You can obtain an access token for your requests using service principals or managed identities.

Authorization is handled by Azure role-based access control (RBAC). Ensure the identity making the request has the necessary permissions (e.g., Contributor, Owner, or a custom role with Analysis Services specific permissions) on the Azure Analysis Services resource.

The access token should be included in the Authorization header of your HTTP requests:

Authorization: Bearer <Your-Access-Token>

Datasets

Datasets represent the tabular models deployed to your Azure Analysis Services server.

List Datasets

GET /servers/{serverName}/databases

Retrieves a list of all datasets (databases) hosted on the specified Azure Analysis Services server.

Request

URL: /servers/{serverName}/databases

Path Parameters:

Name Type Description Required
serverName string The name of the Azure Analysis Services server. Yes

Response

Returns a JSON array of database objects. Each object contains details about a dataset.

Example Response (JSON)

[
  {
    "id": "AdventureWorks",
    "name": "AdventureWorks",
    "state": "Online",
    "creationDate": "2023-01-15T10:00:00Z",
    "lastSchemaUpdate": "2023-10-26T08:30:00Z",
    "webSite": "http://example.com/adventureworks"
  },
  {
    "id": "ContosoRetail",
    "name": "ContosoRetail",
    "state": "Online",
    "creationDate": "2023-05-20T14:00:00Z",
    "lastSchemaUpdate": "2023-11-01T11:00:00Z",
    "webSite": "http://example.com/contosoretail"
  }
]

Models

Models represent the metadata and data within a dataset.

Get Model Metadata

GET /servers/{serverName}/databases/{databaseName}/models

Retrieves the metadata of the model within a specific dataset.

Request

URL: /servers/{serverName}/databases/{databaseName}/models

Path Parameters:

Name Type Description Required
serverName string The name of the Azure Analysis Services server. Yes
databaseName string The name of the dataset (database). Yes

Response

Returns the model's metadata in TOM (Tabular Object Model) JSON format.

Example Response (JSON - Simplified)

{
  "type": "Microsoft.AnalysisServices.Tabular.Model",
  "name": "AdventureWorks",
  "description": "Sales and marketing data for AdventureWorks.",
  "dataSources": [...],
  "tables": [...],
  "relationships": [...],
  "measures": [...]
}

Tables

Operations related to tables within a dataset model.

List Tables

GET /servers/{serverName}/databases/{databaseName}/tables

Retrieves a list of all tables within a specified dataset.

Request

URL: /servers/{serverName}/databases/{databaseName}/tables

Path Parameters:

Name Type Description Required
serverName string The name of the Azure Analysis Services server. Yes
databaseName string The name of the dataset (database). Yes

Response

Returns a JSON array of table objects.

Example Response (JSON)

[
  {
    "id": "DimProduct",
    "name": "DimProduct",
    "description": "Product dimension table.",
    "columns": [...]
  },
  {
    "id": "FactSales",
    "name": "FactSales",
    "description": "Sales fact table.",
    "columns": [...]
  }
]

Columns

Operations related to columns within a table.

List Columns for a Table

GET /servers/{serverName}/databases/{databaseName}/tables/{tableName}/columns

Retrieves a list of columns for a specified table.

Request

URL: /servers/{serverName}/databases/{databaseName}/tables/{tableName}/columns

Path Parameters:

Name Type Description Required
serverName string The name of the Azure Analysis Services server. Yes
databaseName string The name of the dataset (database). Yes
tableName string The name of the table. Yes

Response

Returns a JSON array of column objects.

Example Response (JSON)

[
  {
    "id": "ProductKey",
    "name": "ProductKey",
    "dataType": "int64",
    "isKey": true
  },
  {
    "id": "ProductName",
    "name": "ProductName",
    "dataType": "string"
  }
]

Measures

Operations related to measures within a dataset.

List Measures

GET /servers/{serverName}/databases/{databaseName}/measures

Retrieves a list of all measures within a specified dataset.

Request

URL: /servers/{serverName}/databases/{databaseName}/measures

Path Parameters:

Name Type Description Required
serverName string The name of the Azure Analysis Services server. Yes
databaseName string The name of the dataset (database). Yes

Response

Returns a JSON array of measure objects.

Example Response (JSON)

[
  {
    "id": "TotalSales",
    "name": "Total Sales",
    "expression": "SUM(FactSales[SalesAmount])",
    "formatString": "$#,##0.00"
  },
  {
    "id": "AverageSales",
    "name": "Average Sales",
    "expression": "AVERAGE(FactSales[SalesAmount])",
    "formatString": "$#,##0.00"
  }
]

Relationships

Operations related to relationships between tables in a dataset.

List Relationships

GET /servers/{serverName}/databases/{databaseName}/relationships

Retrieves a list of all relationships within a specified dataset.

Request

URL: /servers/{serverName}/databases/{databaseName}/relationships

Path Parameters:

Name Type Description Required
serverName string The name of the Azure Analysis Services server. Yes
databaseName string The name of the dataset (database). Yes

Response

Returns a JSON array of relationship objects.

Example Response (JSON)

[
  {
    "id": "DimProduct-FactSales",
    "name": "Product to Sales",
    "fromTable": "DimProduct",
    "toTable": "FactSales",
    "fromColumn": "ProductKey",
    "toColumn": "ProductKey",
    "crossFilterDirection": "OneWay"
  }
]

Partitions

Operations related to partitions for tables in a dataset.

List Partitions for a Table

GET /servers/{serverName}/databases/{databaseName}/tables/{tableName}/partitions

Retrieves a list of partitions for a specified table.

Request

URL: /servers/{serverName}/databases/{databaseName}/tables/{tableName}/partitions

Path Parameters:

Name Type Description Required
serverName string The name of the Azure Analysis Services server. Yes
databaseName string The name of the dataset (database). Yes
tableName string The name of the table. Yes

Response

Returns a JSON array of partition objects.

Example Response (JSON)

[
  {
    "id": "FactSales_2023",
    "name": "FactSales_2023",
    "state": "Ready",
    "source": {
      "type": "sql",
      "query": "SELECT * FROM [dbo].[FactSales] WHERE Year = 2023"
    }
  }
]

Queries

Execute queries against the dataset using DAX or MDX.

Execute DAX/MDX Query

POST /servers/{serverName}/databases/{databaseName}/queries

Executes a DAX or MDX query against the specified dataset and returns the results.

Request

URL: /servers/{serverName}/databases/{databaseName}/queries

Path Parameters:

Name Type Description Required
serverName string The name of the Azure Analysis Services server. Yes
databaseName string The name of the dataset (database). Yes

Request Body:

A JSON object containing the query and its type.

Parameters:

  • query (string, required): The DAX or MDX query to execute.
  • queryType (string, required): The type of query, either 'DAX' or 'MDX'.

Example Request Body (JSON)

{
  "query": "EVALUATE SUMMARIZECOLUMNS('DimProduct'[ProductName], 'FactSales'[SalesAmount])",
  "queryType": "DAX"
}

Response

Returns the query results in a structured JSON format, similar to what you would get from a tabular client.

Example Response (JSON)

{
  "results": [
    [
      {"ProductName": "Bike", "SalesAmount": 10000},
      {"ProductName": "Clothing", "SalesAmount": 5000}
    ]
  ]
}

Operations

Monitor the status of asynchronous operations on the server.

List Operations

GET /servers/{serverName}/operations

Retrieves a list of asynchronous operations performed on the server.

Request

URL: /servers/{serverName}/operations

Path Parameters:

Name Type Description Required
serverName string The name of the Azure Analysis Services server. Yes

Response

Returns a JSON array of operation objects, each detailing an ongoing or completed operation.

Example Response (JSON)

[
  {
    "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
    "name": "Refresh: FactSales Partition",
    "status": "Completed",
    "type": "Refresh",
    "startTime": "2023-11-01T10:00:00Z",
    "endTime": "2023-11-01T10:15:00Z",
    "percentComplete": 100,
    "error": null
  },
  {
    "id": "f0e1d2c3-b4a5-6789-0123-456789abcdef",
    "name": "Deploy: AdventureWorks Model",
    "status": "InProgress",
    "type": "Deploy",
    "startTime": "2023-11-01T11:00:00Z",
    "endTime": null,
    "percentComplete": 50,
    "error": null
  }
]