Skip to main content Link Menu Expand (external link) Document Search Copy Copied

To add AI capablities to the application, you need create an Azure OpenAI account and deploy language models. You can use the following guidance:

Step by step guidance

  1. Create an Azure OpenAI account. Run the following commands to create an Azure OpenAI account. Note that the name of the account must be globally unique, so adjust it accordingly in case the randomly generated name is already in use.

    OPEN_AI_SERVICE_NAME=open-ai-account-$UNIQUEID
    az cognitiveservices account create \
       --resource-group $RESOURCE_GROUP \
       --name $OPEN_AI_SERVICE_NAME \
       --location $LOCATION \
       --kind OpenAI \
       --sku s0 \
       --custom-domain $OPEN_AI_SERVICE_NAME
    
  2. Deploy language models in your Azure OpenAI service instance. Use the following commands to deploy two language models text-embedding-ada-002 and gpt-4o.

    az cognitiveservices account deployment create \
       --resource-group $RESOURCE_GROUP \
       --name $OPEN_AI_SERVICE_NAME \
       --deployment-name text-embedding-ada-002 \
       --model-name text-embedding-ada-002 \
       --model-version "2"  \
       --model-format OpenAI \
       --sku-name "Standard" \
       --sku-capacity 1
    
    az cognitiveservices account deployment create \
       --resource-group $RESOURCE_GROUP \
       --name $OPEN_AI_SERVICE_NAME \
       --deployment-name gpt-4o \
       --model-name gpt-4o \
       --model-version 2024-05-13 \
       --model-format OpenAI \
       --sku-name "GlobalStandard" \
       --sku-capacity 1
    

In Azure OpenAI, model availability varies by region. Please check related information to choose the model version.

  1. To securely access Azure OpenAI API call, you need assign Cognitive Services OpenAI User role for your managed identity.
OPEN_AI_RESOURCE_ID=$(az cognitiveservices account show --name $OPEN_AI_SERVICE_NAME --resource-group $RESOURCE_GROUP --query id --output tsv)

SP_ID=$(az identity show --resource-group $RESOURCE_GROUP --name $ACA_IDENTITY --query principalId --output tsv)

az role assignment create \
   --role "Cognitive Services OpenAI User" \
   --scope $OPEN_AI_RESOURCE_ID \
   --assignee $SP_ID