Task 01 - Deploy Azure resources with azd
Introduction
Before you can start building your MCP servers and AI Gateway, you need to deploy the necessary Azure resources. This includes setting up a resource group, deploying Azure infrastructure using Azure Developer CLI (azd), and provisioning all required services for your MCP and AI Gateway solution.
Description
In this task, you will use the Azure Developer CLI (azd) to provision all necessary Azure resources for your MCP and AI Gateway solution. The azd up command will handle creating the resource group, deploying the Bicep infrastructure, and setting up all required services in a single operation. In addition, you will install any software prerequisites needed for the application to run.
Success Criteria
- You have VS Code ready (either in a Codespace or on your local machine).
- You have successfully provisioned Azure resources using
azd up. - You have verified that all Azure resources are deployed correctly.
Learning Resources
- Cloning a repository via the command line or GitHub Desktop
- Azure Developer CLI (azd)
- Get started using Azure Developer CLI (azd)
- Create Bicep files by using Visual Studio Code
Key Tasks
01: Ensure VS Code environment is ready
Before deploying Azure resources, ensure you have Visual Studio Code ready either in a GitHub Codespace or on your local machine. If you haven’t completed the setup yet, refer to Exercise 01: Setup development environment for detailed instructions on:
- Fork/Clone the repository
- Setting up a GitHub Codespace (recommended), or
- Installing necessary software on your local machine (Azure CLI, azd, Python, VS Code, etc.)
02: Provision Azure resources using azd up
After you have set up your development environment, the next step is to provision all necessary Azure resources using the Azure Developer CLI (azd). The azd up command will create a resource group, deploy the Bicep infrastructure, and provision all required Azure services in a single operation.
Expand this section to view the solution
First, ensure that you are logged into both the Azure CLI and the Azure Developer CLI. You can do so using the following commands:
# Login to Azure CLI
az login
# Login to Azure Developer CLI
azd auth login
If you are using a GitHub Codespace, use
az login --use-device-codeto authenticate with Azure CLI.
If you receive an error message reading, “Your sign-in was successful but does not meet the criteria to access this resource,” you are likely using a Microsoft EMU account or some other account that has stringent restrictions on machine access. You will need to use an external MCAPS subscription or some other paid subscription to continue. A Visual Studio subscription will not be sufficient, as these accounts will likely not have access to Microsoft Foundry and the language models we will use.
Once authenticated, navigate to the root directory of the repository in your terminal and run the azd up command to provision the Azure resources:
azd up
The azd up command will prompt you for the following information:
- Environment name: Enter a name for your environment (e.g.,
kbtg-group08). This will be used to generate unique resource names. - Subscription: Select the Azure subscription where you want to deploy the resources.
- Location: Select the region where you want to deploy the resources. Use swedencentral as it contains more AI models than other regions.
If you receive an error message indicating that you do not have sufficient VM quota in the given region, try a different region from the four listed above:
eastus2,swedencentral,francecentral,switzerlandwest. If your account does not have sufficient quota in any of those four regions, you may create resources in another region but you will not be able to run the Red Teaming agent in Exercise 06.
After you provide this information, azd will begin provisioning your Azure resources. This process may take 10-15 minutes to complete. You can monitor the progress in the terminal.
Once the deployment is complete, azd will display a summary of the deployed resources and their endpoints. You can also view the deployment in the Azure portal by navigating to the resource group that was created.