Create Azure OpenAI Resources Using Azure CLI

In this Azure CLI and OpenAI blog post, we will create an Azure OpenAI resource using Azure CLI.

Using Azure CLI to create resources allows us to streamline the process of deploying resources to Azure with the same configuration over and over. Azure OpenAI allow us to use AI services like ChatGPT using Azure infrastructure.

Installing Azure CLI on your machine (Linux, Windows, macOS) to get started.

Deploy Azure OpenAI Resource

In order to use Azure OpenAI services, we need to deploy an Azure OpenAI resource that will allow us access to the OpenAI API service.

The following Azure CLI script will deploy and Azure OpenAI service. If you look at the code, you will see that we use the cognitiveservices CLI to deploy the service.

# Set variables
$resourceGroupName = "NTW-OPENAI-LAB"
$location = "eastus"
$cognitiveServiceName = "NTWConversationsAI"
$modelName = "gpt-4"
$modelVersion = "0613"

# Create resource group
az group create --name $resourceGroupName --location $location

# Create cognitive service account
az cognitiveservices account create -n $cognitiveServiceName -g $resourceGroupName -l $location --kind OpenAI --sku s0

# Create deployment for cognitive service account
az cognitiveservices account deployment create -g $resourceGroupName -n $cognitiveServiceName --deployment-name ntweekly --model-name $modelName --model-version $modelVersion --model-format OpenAI 

# Get endpoint of cognitive service account
az cognitiveservices account show -g $resourceGroupName -n $cognitiveServiceName --query "properties.endpoint"

# Get keys of cognitive service account
az cognitiveservices account keys list -g $resourceGroupName -n $cognitiveServiceName --query "key1"

The code will also output the OpenAI endpoint and access key to configure a .NET application.

More AI articles

Processing…
Success! You're on the list.

Posted

in

, , ,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.