If haven’t been living under a rock, you know that Azure OpenAI is a powerful tool that brings the cutting-edge capabilities of OpenAI’s models to the cloud, offering scalability, reliability, and integration with Azure’s vast ecosystem.
Because I am who I am we will use PowerShell to setup our Azure OpenAI instance. Whether you’re automating deployment or integrating Azure OpenAI into your existing infrastructure, PowerShell scripts can simplify the process. Let’s get started with a step-by-step guide to setting up your Azure OpenAI instance using PowerShell.
Prerequisites
Before we dive into the commands, ensure you have the following:
- An Azure subscription. If you don’t have one, you can create a free account.
- PowerShell installed on your system. If you’re on Windows, you’re probably already set. For Mac and Linux users, check out PowerShell Core.
- The Azure PowerShell module installed. You can install it by running
Install-Module -Name Az -AllowClobber -Scope CurrentUser
in your PowerShell terminal.
Step 1: Log in to Azure
First things first, let’s log into Azure. Open your PowerShell terminal and run:
Connect-AzAccount
This command opens a login window where you can enter your Azure credentials. Once authenticated, you’re ready to proceed.
Step 2: Create a Resource Group
Azure OpenAI instances need to reside in a resource group, a container that holds related resources for an Azure solution. To create a new resource group, use:
New-AzResourceGroup -Name 'MyResourceGroup' -Location 'EastUS'
Replace 'MyResourceGroup'
with your desired resource group name and 'EastUS'
with your preferred location.
Step 3: Register the OpenAI Resource Provider
Before deploying Azure OpenAI, ensure your subscription is registered to use the OpenAI resource provider. Register it with:
powershell
Register-AzResourceProvider -ProviderNamespace 'Microsoft.OpenAI'
This command might take a few minutes. To check the status, you can run Get-AzResourceProvider -ProviderNamespace 'Microsoft.OpenAI'
.
Step 4: Create an Azure OpenAI Instance
Now, the exciting part—creating your Azure OpenAI instance. Use the following command:
powershell
New-AzResource -ResourceGroupName 'MyResourceGroup' -ResourceType 'Microsoft.OpenAI/workspaces' -Name 'MyOpenAIInstance' -Location 'EastUS' -PropertyObject @{ sku = 'S0'; properties = @{ description = 'My Azure OpenAI instance for cool AI projects'; } }
Make sure to replace 'MyResourceGroup'
, 'MyOpenAIInstance'
, and 'EastUS'
with your resource group name, desired OpenAI instance name, and location, respectively.
Step 5: Confirm Your Azure OpenAI Instance
To ensure everything went smoothly, you can list all OpenAI instances in your resource group:
powershell
Get-AzResource -ResourceGroupName 'MyResourceGroup' -ResourceType 'Microsoft.OpenAI/workspaces'
This command returns details about the OpenAI instances in your specified resource group, confirming the successful creation of your instance. Enjoy your brand new OpenAI instance!