Microsoft Azure documentation
Configure Azure Machine Learning and Microsoft Foundry
Configure Azure Machine Learning and Microsoft Foundry
Throughout this guide you’ll see references to both Azure AI Foundry and Microsoft Foundry simultaneously, but that’s because Microsoft Foundry has superseded Azure AI Foundry, but still referencing to it for the “classic” experience, which is the one that supports Hub-based projects and then, models from the Hugging Face Hub.
This guide explains how to configure Azure Machine Learning and Microsoft Foundry in your Microsoft Azure subscription. These pre-requisites are required to run the Microsoft Foundry examples in this documentation, as well as any example on Azure Machine Learning.
You can either follow along the below steps, or either read more about those in the Azure Machine Learning Tutorial: Create resources you need to get started.
Also note that the steps below will use the az CLI i.e., the Azure CLI, but there are other alternatives such as e.g. the Azure SDK for Python, or even the Azure Portal, so pick the one you feel more comfortable with.
Azure Account
A Microsoft Azure account with an active subscription. If you don’t have a Microsoft Azure account, you can now create one for free, including 200 USD worth of credits to use within the next 30 days after the account creation.
Azure CLI
The Azure CLI (az) installed on the instance that you’re running this example on, see the installation steps, and follow the steps of the preferred method based on your instance. Then log in into your subscription as follows:
az login
More information at Sign in with Azure CLI - Login and Authentication.
Azure CLI extension for Azure Machine Learning
Besides the Azure CLI (az), you also need to install the Azure Machine Learning CLI extension (az ml) which will be used to create the Azure Machine Learning and Microsoft Foundry required resources.
First you will need to list the current extensions and remove any ml-related extension before installing the latest one i.e., v2.
az extension list az extension remove --name azure-cli-ml az extension remove --name ml
Then you can install the az ml v2 extension as follows:
az extension add --name ml
More information at Azure Machine Learning (ML) - Install and setup the CLI (v2).
Azure Resource Group
az group create --name huggingface-azure-rg --location eastus
Then, you can ensure that the resource group was created successfully by e.g. listing all the available resource groups that you have access to on your subscription:
az group list --output table
More information at Manage Azure resource groups by using Azure CLI.
You can also create the Azure Resource Group via the Azure Portal, or via the Azure Resource Management Python SDK (requires it to be installed as
pip install azure-mgmt-resourcein advance).
Azure AI Foundry Hub-based project
An Azure AI Foundry Hub-based project (given that the new experience on Microsoft Foundry does not yet support Hugging Face models, but rather only the classic experience which is the same as saying Azure AI Foundry) under the aforementioned subscription and resource group. If you don’t have one, you can create it as follows:
az ml workspace create \
--kind hub \
--name huggingface-azure-hub \
--resource-group huggingface-azure-rg \
--location eastusThen, you can ensure that the workspace was created successfully by e.g. listing all the available workspaces that you have access to on your subscription:
az ml workspace list --filtered-kinds hub --query "[].{Name:name, Kind:kind}" --resource-group huggingface-azure-rg --output tableThe
--filtered-kindsargument has been recently included as of Azure Machine Learning CLI 2.37.0, meaning that you may need to upgradeaz mlasaz extension update --name ml.
Once the Azure AI Foundry Hub-based project is created, you need to create an Azure AI Foundry project linked to that Hub, to do so you first need to obtain the Azure AI Foundry Hub ID of the recently created Hub as follows (replace the resource names with yours):
az ml workspace show \
--name huggingface-azure-hub \
--resource-group huggingface-azure-rg \
--query "id" \
-o tsvThat command will provide the ID as follows /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.MachineLearningServices/workspaces/huggingface-azure-hub, meaning that you can also format it manually yourself with the appropriate replacements. Then you need to run the following command to create the Microsoft Foundry Project for that Hub as:
az ml workspace create \
--kind project \
--hub-id $(az ml workspace show --name huggingface-azure-hub --resource-group huggingface-azure-rg --query "id" -o tsv) \
--name huggingface-azure-project \
--resource-group huggingface-azure-rg \
--location eastusFinally, you can verify that it was correctly created with the following command:
az ml workspace list --filtered-kinds project --query "[].{Name:name, Kind:kind}" --resource-group huggingface-azure-rg --output tableMore information at How to create and manage an Azure AI Foundry Hub and at How to create a Hub using the Azure CLI.
Update on GitHubYou can also create the Azure AI Foundry Hub via the Azure Portal, or via the Azure Machine Learning Python SDK, among other options listed in Manage AI Hub Resources.