# Automated deployment and replacement of Scoring Code in AzureML
URL: https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/prediction-env/pred-env-integrations/azureml-sc-deploy-replace.html

> Create a DataRobot-managed AzureML prediction environment to deploy and replace DataRobot Scoring Code in AzureML.

# Automated deployment and replacement of Scoring Code in AzureML

> [!NOTE] Premium
> Automated deployment and replacement of Scoring Code in AzureML is a premium feature. Contact your DataRobot representative or administrator for information on enabling this feature.
> 
> Feature flag: Enable the Automated Deployment and Replacement of Scoring Code in AzureML ( Premium feature)

Create a DataRobot-managed AzureML prediction environment to deploy DataRobot Scoring Code in AzureML. With DataRobot management enabled, the external AzureML deployment has access to MLOps features, including automatic Scoring Code replacement.

> [!NOTE] Service health information for external models and monitoring jobs
> Service health information is unavailable for external [agent-monitored deployments](https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/mlops-agent/monitoring-agent/index.html) and deployments with predictions uploaded through a [prediction monitoring job](https://docs.datarobot.com/en/docs/classic-ui/predictions/batch/pred-monitoring-jobs/index.html).

## Create an AzureML prediction environment

To deploy a model in AzureML, you first create a custom AzureML prediction environment:

1. ClickDeployments > Prediction Environmentsand then clickAdd prediction environment.
2. In theAdd prediction environmentdialog box, configure the prediction environment settings:
3. Configure theAzure Subscription,Azure Resource Group, andAzureML Workspacefields accessible using the providedCredentials.
4. (Optional) If you want to connect to and retrieve data from Azure Event Hubs for monitoring, configure theEvent Hubs Namespace,Event Hubs Instance, andManaged Identitiesfields. This requires validCredentials, anAzure Subscription ID, and anAzure Resource Group.
5. (Optional) If you are using tags for governance and resource management in AzureML, clickAdd AzureML tagsand then+ Add new tagto add the required tags to the prediction environment.
6. After you configure the environment settings, clickAdd environment. The AzureML environment is now available from thePrediction Environmentspage.

## Deploy a model to the AzureML prediction environment

Once you've created an AzureML prediction environment, you can deploy a model to it:

1. ClickModel Registry > Registered Modelsand select the Scoring Code enabled registered model version you want to deploy to the AzureML prediction environment. TipYou can also deploy a model to your AzureML prediction environment from theDeployments>Prediction Environmentstab by clicking+ Add new deploymentin the prediction environment.
2. On any tab in the registered model version, clickDeploy.
3. In theSelect Deployment Targetdialog box, underSelect deploy target, clickAzureML. NoteIf you can't click the AzureML deployment target, the selected model doesn't have Scoring Code available.
4. UnderSelect prediction environment, select the AzureML prediction environment you added, and then clickConfirm.
5. Configure the deploymentand, in thePrediction History and Service Healthsection, underEndpoint, click+ Add endpoint.
6. In theSelect endpointdialog box, define anOnlineorBatchendpoint, depending on your expected workload, and then clickNext.
7. (Optional) Define additionalEnvironment key-value pairsto provide extra parameters to the Azure deployment interface, then clickConfirm.
8. ClickDeploy model. While the deployment isLaunching, you can monitor the status events on theService Healthtab inRecent Activity > Agent Activity:

## Make predictions in AzureML

After you deploy a model to an AzureML prediction environment, you can use the code snippet from the Predictions > Portable Predictions tab to score data in AzureML.

Before you run the code snippet, you must provide the required credentials in either of the following ways:

- Export the Azure Service Principal’s secrets as environment variables locally before running the snippet: Environment variableDescriptionAZURE_CLIENT_IDTheApplication IDin theApp registration > Overviewtab.AZURE_TENANT_IDTheDirectory IDin theApp registration > Overviewtab.AZURE_CLIENT_SECRETThe secret token generated in theApp registration > Certificates and secretstab.
- Install theAzure CLI, and run theaz logincommand to allow the portable predictions snippet to use your personal Azure credentials.

> [!NOTE] Important
> Deployments to AzureML Batch and Online endpoints utilize different APIs than standard DataRobot deployments.
> 
> Online endpoints support JSON or CSV as input and outputs results to JSON.
> Batch endpoints support CSV input and output the results to a CSV file.

---
