This is a C# implementation of mslearn-ai-agents, which is used as part of the Microsoft Learn Develop AI agents on Azure learning path.
The C# code takes advantage of .NET 10 file-based apps. You will need the latest .NET 10 SDK installed.
The exercises in this repo are designed to provide you with a hands-on learning experience in which you'll explore common tasks that developers perform when building AI agents on Microsoft Azure.
Note: To complete the exercises, you'll need an Azure subscription in which you have sufficient permissions and quota to provision the necessary Azure resources and generative AI models. If you don't already have one, you can sign up for an Azure account. There's a free trial option for new users that includes credits for the first 30 days.
Note that not all regions support all features of Azure AI Vision. See https://learn.microsoft.com/azure/ai-services/computer-vision/overview-image-analysis?WT.mc_id=DOP-MVP-5001655 for details.
az group create --location eastus2 --resource-group rg-mslearn-ai-agents-eastus2-001# Prepare a service principal for Login with OIDC
az ad sp create-for-rbac --name sp-mslearn-ai-agents-eastus2-001 --role Contributor --scopes /subscriptions/<yoursubscription>/resourceGroups/rg-mslearn-ai-agents-eastus2-001Make a note of the appId value, as you'll enter that as the --id parameter.
Create credential.json (update octo-org and octo-repo to the GitHub organisation/username and repository name respectively)
{
"name": "main",
"issuer": "https://token.actions.githubusercontent.com",
"subject": "repo:octo-org/octo-repo:ref:refs/heads/main",
"description": "Main branch",
"audiences": [
"api://AzureADTokenExchange"
]
}Use the appId value from above for the --id parameter
az ad app federated-credential create --id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --parameters credential.jsonGet the Azure subscription ID:
az account subscription listAdd a role assignment so that the service principal has permissions to purge deleted Azure AI Foundries. Use appId for the --assignee value, and set --scope to your Azure subscription:
az role assignment create --assignee xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --role "Cognitive Services Contributor" --scope /subscriptions/yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyyFinally, set the following as GitHub secrets
AZURE_CLIENT_IDthe Application (client) IDAZURE_TENANT_IDthe Directory (tenant) IDAZURE_SUBSCRIPTION_IDyour subscription ID
eg. via the GitHub CLI
gh secret set AZURE_CLIENT_ID --body "xxxx"
gh secret set AZURE_TENANT_ID --body "xxxx"
gh secret set AZURE_SUBSCRIPTION_ID --body "xxxxx"