Microsoft Azure Analysis Services Operators¶
Use these components to start and monitor asynchronous model refresh operations in Microsoft Azure Analysis Services. Configure an Azure Analysis Services connection before using them.
Prerequisite Tasks¶
To use these operators, you must do a few things:
Create necessary resources using AZURE PORTAL or AZURE CLI.
Install API libraries via pip.
pip install 'apache-airflow[azure]'Detailed information is available Installation of Airflow®
Start a model refresh¶
Use AzureAnalysisServicesRefreshOperator
with wait_for_termination=False to start a refresh and immediately return its refresh ID.
start_refresh_without_wait = AzureAnalysisServicesRefreshOperator(
task_id="start_refresh_without_wait",
server_name=SERVER_NAME,
database=DATABASE,
refresh_type=REFRESH_TYPE,
wait_for_termination=False,
)
Wait for the refresh to finish¶
With the default wait_for_termination=True the operator also waits for the refresh to reach a
terminal status. The timeout parameter limits that wait and starts once the refresh has been
submitted, while request_timeout limits each individual REST request.
refresh_and_wait = AzureAnalysisServicesRefreshOperator(
task_id="refresh_and_wait",
server_name=SERVER_NAME,
database=DATABASE,
refresh_type=REFRESH_TYPE,
check_interval=10,
timeout=600,
)
Note
The operator and the sensor always run deferred. Both the request that starts the refresh and the status polling are performed by the triggerer, so no worker slot is held while the model is refreshing. A triggerer must be running in your deployment.
Wait with a sensor¶
The operator return value can be passed directly to
AzureAnalysisServicesSensor.
This separates starting the refresh from waiting for it.
wait_for_refresh = AzureAnalysisServicesSensor(
task_id="wait_for_refresh",
server_name=SERVER_NAME,
database=DATABASE,
refresh_id=start_refresh_without_wait.output,
poke_interval=10,
timeout=600,
)
Azure Analysis Services accepts only one active refresh for a model. A second request returns HTTP 409, so serialize refresh tasks that target the same model, for example with task dependencies or an Airflow pool.
Reference¶
For more information, see Asynchronous refresh with the REST API.