Automate the analysis


This section explains how to automate VPAX file analysis using command-line tools (CLI) and integrate the analysis into a DevOps YAML pipeline.

WARNING: Before proceeding, ensure that you have a group account and an active license that supports automation.

Here are the steps to automate an analysis:

Samples:

Videos:

Step1: Install the VPAX CLI tool

Install the Dax.Vpax.CLI tool by running the following command in your terminal:

dotnet tool install Dax.Vpax.CLI --global

After installation, you can invoke the tool with vpax --help

Step2: Extract the VPAX file

Execute the following command in your terminal to extract the VPAX file from the tabular model:

vpax export "C:\path\to\file.vpax" "Provider=MSOLAP;Data Source=<SERVER>;Initial Catalog=<DATABASE>;" 

NOTE: Configure the file path and the connection string arguments based on your environment. Use vpax export --help and read the VPAX command line documentation to learn more.

If you use a Power BI workspace, you should enable and use the Service Principal to access the XMLA endpoint. Read more about this in the following articles:

Step3: Create a Personal Access Token

  1. Go to app.daxoptimizer.com.
  2. Switch to the group account that owns the target model you wish to automate the analysis for.
  3. Select Access Tokens from the account’s settings panel.

    Access Tokens menu

  4. Click on the + Token button.

    Personal Access Tokens dialog box

  5. Specify a name and expiration date, then click Create.

    Access Tokens menu

  6. Make sure to copy the new access token now as you won’t be able to see it again.

    Access Tokens menu

    NOTE: You can create a maximum of 5 access tokens with expiration dates ranging from 7 days to one year.

Step4: Install the DAX Optimizer CLI tool

Install the Dax.Optimizer.CLI tool by running the following command in your terminal:

dotnet tool install Dax.Optimizer.CLI --global

After installation, you can invoke the tool with daxoptimizer --help

Step5: Analyze the VPAX file

Here are the steps to follow to automatically generate the CLI command to run the analysis:

  1. Go to app.daxoptimizer.com.
  2. Switch to the group account that owns the target model you wish to automate the analysis for.
  3. Select Command Line from the target model’s context menu.
  4. Copy and configure the auto-generated CLI command by replacing the placeholders with the required information, such as VPAX path and personal access token.

Use the auto-generated CLI command to upload and analyze in Dax Optimizer service the previously extracted VPAX file.

NOTE: Use daxoptimizer analyze --help to learn more about the available arguments.

Here is an example of the auto-generated CLI command:

daxoptimizer analyze "<VPAX_PATH>" \
    --workspace-id "261683679063-aefa766b-9b3d-44b2-bb0b-6903495c8819" \
    --model-id "241683679036-97f18fb0-91f6-4b29-bdc5-c2b0c7023f1c" \
    --region "eastus" \
    --username "contoso-team" \
    --password "<PERSONAL_ACCESS_TOKEN>"

Sample: Azure DevOps YML pipeline

Here is an example of automation using an Azure DevOps YAML pipeline:

trigger: none

pool:
  vmImage: ubuntu-latest

variables:
  # Define a variable to store the path where the VPAX file will be extracted.
  # Using $(Build.BuildId) ensures a unique file name for each build.
  vpaxPath: '$(Build.StagingDirectory)/contoso-$(Build.BuildId).vpax'

steps:
  - script: dotnet tool install Dax.Vpax.CLI --global
    displayName: install vpax tool

  - script: dotnet tool install Dax.Optimizer.CLI --global
    displayName: install daxoptimizer tool

  - script: vpax export '$(vpaxPath)' "$TABULAR_CONNECTION_STRING"
    displayName: export vpax
    env:
      TABULAR_CONNECTION_STRING: $(ConnectionString)

  - script: daxoptimizer analyze '$(vpaxPath)' -w '$(WorkspaceId)' -m '$(ModelId)' -r '$(Region)' -u '$(Username)' -p "$DAXOPTIMIZER_TOKEN"
    displayName: analyze vpax
    env:
      DAXOPTIMIZER_TOKEN: $(PersonalAccessToken)

Overview video

See how to automate the analysis of a VPAX file using the CLI tools:

Last update: Dec 16, 2024