| author | cephalin | |
|---|---|---|
| ms.service | azure-app-service | |
| ms.topic | include | |
| ms.date | 03/03/2026 | |
| ms.author | cephalin | |
| ms.custom |
|
In this section, you use Azure CLI in GitHub Codespaces to create an Azure OpenAI resource.
-
Sign in to GitHub Codespaces with your GitHub account.
-
Select Use this template in the Blank tile to create a new blank codespace.
-
In the Codespace terminal, install the Azure CLI.
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash -
Sign in to your Azure account.
az loginFollow the instructions in the terminal to authenticate.
-
Set environment variables by providing names for your resource group and Azure OpenAI service and setting an appropriate Azure region as your location.
export RESOURCE_GROUP="<group-name>" export OPENAI_SERVICE_NAME="<azure-openai-name>" export APPSERVICE_NAME="<app-name>" export LOCATION="<azure-region>"[!IMPORTANT] The location is tied to the regional availability of the chosen model. Model and deployment type availability vary among Azure regions and billing tiers. This tutorial uses
gpt-4o-mini, which is available in several regions under the Standard deployment type.Before selecting a location, consult the Model summary and region availability table to verify model support in your preferred region.
-
Create a resource group and an Azure OpenAI resource with a custom domain, and then add a
gpt-4o-minimodel:# Resource group az group create --name $RESOURCE_GROUP --location $LOCATION # Azure OpenAI resource az cognitiveservices account create \ --name $OPENAI_SERVICE_NAME \ --resource-group $RESOURCE_GROUP \ --location $LOCATION \ --custom-domain $OPENAI_SERVICE_NAME \ --kind OpenAI \ --sku s0 # gpt-4o-mini model az cognitiveservices account deployment create \ --name $OPENAI_SERVICE_NAME \ --resource-group $RESOURCE_GROUP \ --deployment-name gpt-4o-mini \ --model-name gpt-4o-mini \ --model-version 2024-07-18 \ --model-format OpenAI \ --sku-name Standard \ --sku-capacity 1 # Cognitive Services OpenAI User role that lets the signed in Azure user read models from Azure OpenAI az role assignment create \ --assignee $(az ad signed-in-user show --query id -o tsv) \ --role "Cognitive Services OpenAI User" \ --scope /subscriptions/$(az account show --query id -o tsv)/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.CognitiveServices/accounts/$OPENAI_SERVICE_NAME
Now that you have an Azure OpenAI resource, you can create a web application to interact with it.