> ## Documentation Index
> Fetch the complete documentation index at: https://zenml.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AzureML

> How to execute individual steps in AzureML

The AzureML step operator is a [step operator](/component-gallery/step-operators) flavor provided with the ZenML `azure` integration that uses [AzureML](https://azure.microsoft.com/en-us/services/machine-learning/) to execute individual steps of ZenML pipelines.

### When to use it

You should use the AzureML step operator if:

* one or more steps of your pipeline require computing resources (CPU, GPU, memory) that are not provided by your orchestrator.

* you have access to AzureML. If you're using a different cloud provider, take a look at the [SageMaker](/component-gallery/step-operators/amazon-sagemaker) or [Vertex](/component-gallery/step-operators/gcloud-vertexai) step operators.

### How to deploy it

* Create a `Machine learning` [resource on Azure](https://docs.microsoft.com/en-us/azure/machine-learning/quickstart-create-resources).

* Once your resource is created, you can head over to the `Azure Machine Learning Studio` and [create a compute cluster](https://docs.microsoft.com/en-us/azure/machine-learning/quickstart-create-resources#cluster) to run your pipelines.

* Create an `environment` for your pipelines. Follow [this guide](https://docs.microsoft.com/en-us/azure/machine-learning/how-to-manage-environments-in-studio) to set one up.

* (Optional) Create a [Service Principal](https://docs.microsoft.com/en-us/azure/developer/java/sdk/identity-service-principal-auth) for authentication. This is required if you intend to run your pipelines with a remote orchestrator.

### How to use it

To use the AzureML step operator, we need:

* The ZenML `azure` integration installed. If you haven't done so, run

```
zenml integration install azure  
```

* An AzureML compute cluster and environment. See the [deployment section](/component-gallery/step-operators/azureml#how-do-you-deploy-it) for detailed instructions.

* A [remote artifact store](/component-gallery/artifact-stores) as part of your stack. This is needed so that both your orchestration environment and AzureML can read and write step artifacts. Check out the documentation page of the artifact store you want to use for more information on how to set that up and configure authentication for it.

We can then register the step operator and use it in our active stack:

```
zenml step-operator register  \
    --flavor=azureml \
    --subscription_id= \
    --resource_group= \
    --workspace_name= \
    --compute_target_name= \
    --environment_name= \
# only pass these if using Service Principal Authentication
#   --tenant_id= \
#   --service_principal_id= \
#   --service_principal_password= \

# Add the step operator to the active stack
zenml stack update -s 
```

Once you added the step operator to your active stack, you can use it to execute individual steps of your pipeline by specifying it in the `@step` decorator as follows:

```
from zenml.steps import step

@step(step_operator=)
def trainer(...) -> ...:
    """Train a model."""
    # This step will be executed in AzureML.
```

ZenML will build a Docker image called `<CONTAINER_REGISTRY_URI>/zenml:<PIPELINE_NAME>` which includes your code and use it to run your steps in AzureML. Check out [this page](/advanced-guide/pipelines/containerization) if you want to learn more about how ZenML builds these images and how you can customize them.

#### Additional configuration

For additional configuration of the AzureML step operator, you can pass `AzureMLStepOperatorSettings` when defining or running your pipeline. Check out the [API docs](https://apidocs.zenml.io/latest/integration%5Fcode%5Fdocs/integrations-azure/#zenml.integrations.azure.flavors.azureml%5Fstep%5Foperator%5Fflavor.AzureMLStepOperatorSettings) for a full list of available attributes and [this docs page](/advanced-guide/pipelines/settings) for more information on how to specify settings.

A concrete example of using the AzureML step operator can be found [here](https://github.com/zenml-io/zenml/tree/main/examples/step%5Foperator%5Fremote%5Ftraining).

For more information and a full list of configurable attributes of the AzureML step operator, check out the [API Docs](https://apidocs.zenml.io/latest/integration%5Fcode%5Fdocs/integrations-azure/#zenml.integrations.azure.step%5Foperators.azureml%5Fstep%5Foperator.AzureMLStepOperator).

#### Enabling CUDA for GPU-backed hardware

Note that if you wish to use this step operator to run steps on a GPU, you will need to follow [the instructions on this page](/advanced-guide/pipelines/gpu-hardware) to ensure that it works. It requires adding some extra settings customization and is essential to enable CUDA for the GPU to give its full acceleration.
