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
- Get Started With Azure Open AI .NET SDK
- Use Azure OpenAI with C# Application
- Deploy Azure OpenAI Resource With Terraform
- Connect to Azure OpenAI Using Postman
- Azure AI vs Azure Open AI
- Azure AI Studio vs Microsoft Copilot Studio
- Get Started With Azure AI Studio
- Create Prompt Flow for an LLM App in Azure AI Studio
- Detect Language using Azure AI Services
- Use GitHub Copilot to Write and Manage Code
- Install and use GitHub Copilot with Visual Studio
- Build Copilot With Azure AI Studio and Add Your Data
- Create Azure OpenAI Resource Using Azure CLI