Sharing Assets with Registries
This lesson explains what a registry stores, how registries are created and used, and how they promote models and environments between workspaces and regions.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the assets a registry can hold.
- Identify the registry properties that cannot change.
- Explain how to create assets in a registry.
- Describe promotion with az ml model share.
What a registry is
An Azure Machine Learning registry is a resource, separate from any workspace, that stores models, environments, components and data. Any workspace in the organization that has permission and is in one of the registry's regions can use its assets. Jobs, compute and endpoints are not stored in registries, because they belong to a workspace.
A registry has a primary region and optional replication regions. Azure provisions storage in each region and a container registry replicated to each, so that a workspace in any of those regions reads assets locally. Microsoft's own curated environments and components are published in a registry named azureml, which is why curated environments have URIs that start with azureml://registries/azureml.
Creating a registry
A registry is created from a YAML file with az ml registry create. Its name must be 2 to 32 characters of letters, digits, hyphens and underscores, and it cannot be changed later because it is part of every asset ID. The primary region also cannot be changed, but replication regions can be updated.
# registry.yml
name: contoso-ml
location: westeurope
replication_locations:
- location: westeurope
- location: swedencentral
- location: eastus2az ml registry create --resource-group rg-ml-shared --file registry.ymlAccess is controlled with Azure roles. AzureML Registry User lets people and workflows read, create and delete assets; Reader allows read-only use; Contributor or Owner is needed to create or delete the registry itself.
Creating and using registry assets
The same az ml commands that create assets in a workspace create them in a registry when --registry-name replaces --workspace-name. Jobs and deployments in any connected workspace then reference them with a registry URI.
| Asset | Create in registry | Reference from a workspace |
|---|---|---|
| Environment | az ml environment create --file env.yml --registry-name contoso-ml | azureml://registries/contoso-ml/environments/train-env/versions/2 |
| Component | az ml component create --file train.yml --registry-name contoso-ml | azureml://registries/contoso-ml/components/train_churn_model/versions/3 |
| Model | az ml model create --name churn --version 4 --type mlflow_model --path ./model --registry-name contoso-ml | azureml://registries/contoso-ml/models/churn/versions/4 |
Assets in a registry must be complete in themselves. A component in a registry, for example, must reference an environment that is also in a registry, not one that exists only in a workspace, because other workspaces could not resolve it.
Promotion with registries
Registries make the development-to-production promotion clean. A model trained and validated in the development workspace is copied into the registry with az ml model share, which requires a name and version for the registry copy. The production workspace deploys the model from the registry URI. The production team needs no access to the development workspace, and the development team needs no access to production.
az ml model share --name churn --version 7 \
--resource-group rg-ml-dev --workspace-name mlw-churn-dev \
--registry-name contoso-ml --share-with-name churn --share-with-version 7One model across regions
A company trains a fraud model in a workspace in West Europe. It must serve the same validated model version from production workspaces in West Europe and East US 2. Production teams in each region must not have access to the training workspace or its data.
Create a registry with West Europe as the primary region and East US 2 as a replication region. After validation, share the model from the training workspace to the registry. Each production workspace deploys it with its registry URI, reading the replicated copy in its own region, and production teams receive AzureML Registry User or Reader on the registry rather than any role on the training workspace.
Retraining the model in East US 2 would require data access there and would produce a different model. Downloading the model and uploading it to the second workspace would lose lineage and depend on a manual step. Giving East US 2 operators Reader on the training workspace breaks the access requirement.
Which two properties of an Azure Machine Learning registry cannot be changed after it is created?
Show answer
Its name and its primary region. Additional regions can be added, but the name and primary region must be chosen correctly at creation.
Exam Tips
Remember for the exam
- Registries store models, environments, components and data for many workspaces.
- A registry's name and primary region cannot be changed.
- Use --registry-name instead of --workspace-name to create assets in a registry.
- az ml model share copies a validated model from a workspace into a registry.