{"id":649,"date":"2023-11-24T13:29:00","date_gmt":"2023-11-24T13:29:00","guid":{"rendered":"http:\/\/draith.com\/?p=649"},"modified":"2024-02-08T01:33:23","modified_gmt":"2024-02-08T01:33:23","slug":"setting-up-azure-openai-with-powershell","status":"publish","type":"post","link":"https:\/\/draith.com\/?p=649","title":{"rendered":"Setting up Azure OpenAI with PowerShell"},"content":{"rendered":"\n<p>If haven&#8217;t been living under a rock, you know that Azure OpenAI is a powerful tool that brings the cutting-edge capabilities of OpenAI&#8217;s models to the cloud, offering scalability, reliability, and integration with Azure&#8217;s vast ecosystem.<\/p>\n\n\n\n<p>Because I am who I am we will use PowerShell to setup our Azure OpenAI instance. Whether you&#8217;re automating deployment or integrating Azure OpenAI into your existing infrastructure, PowerShell scripts can simplify the process. Let&#8217;s get started with a step-by-step guide to setting up your Azure OpenAI instance using PowerShell.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Prerequisites<\/h4>\n\n\n\n<p>Before we dive into the commands, ensure you have the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>An Azure subscription. If you don&#8217;t have one, you can create a free account.<\/li>\n\n\n\n<li>PowerShell installed on your system. If you&#8217;re on Windows, you&#8217;re probably already set. For Mac and Linux users, check out PowerShell Core.<\/li>\n\n\n\n<li>The Azure PowerShell module installed. You can install it by running <code>Install-Module -Name Az -AllowClobber -Scope CurrentUser<\/code> in your PowerShell terminal.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Step 1: Log in to Azure<\/h4>\n\n\n\n<p>First things first, let&#8217;s log into Azure. Open your PowerShell terminal and run:<\/p>\n\n\n\n<p><code>Connect-AzAccount<\/code><\/p>\n\n\n\n<p>This command opens a login window where you can enter your Azure credentials. Once authenticated, you&#8217;re ready to proceed.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 2: Create a Resource Group<\/h4>\n\n\n\n<p>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:<\/p>\n\n\n\n<p><code>New-AzResourceGroup -Name 'MyResourceGroup' -Location 'EastUS'<\/code><\/p>\n\n\n\n<p>Replace <code>'MyResourceGroup'<\/code> with your desired resource group name and <code>'EastUS'<\/code> with your preferred location.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 3: Register the OpenAI Resource Provider<\/h4>\n\n\n\n<p>Before deploying Azure OpenAI, ensure your subscription is registered to use the OpenAI resource provider. Register it with:<\/p>\n\n\n\n<p>powershell<\/p>\n\n\n\n<p><code>Register-AzResourceProvider -ProviderNamespace 'Microsoft.OpenAI'<\/code><\/p>\n\n\n\n<p>This command might take a few minutes. To check the status, you can run <code>Get-AzResourceProvider -ProviderNamespace 'Microsoft.OpenAI'<\/code>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 4: Create an Azure OpenAI Instance<\/h4>\n\n\n\n<p>Now, the exciting part\u2014creating your Azure OpenAI instance. Use the following command:<\/p>\n\n\n\n<p>powershell<\/p>\n\n\n\n<p><code>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'; } }<\/code><\/p>\n\n\n\n<p>Make sure to replace <code>'MyResourceGroup'<\/code>, <code>'MyOpenAIInstance'<\/code>, and <code>'EastUS'<\/code> with your resource group name, desired OpenAI instance name, and location, respectively.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 5: Confirm Your Azure OpenAI Instance<\/h4>\n\n\n\n<p>To ensure everything went smoothly, you can list all OpenAI instances in your resource group:<\/p>\n\n\n\n<p>powershell<\/p>\n\n\n\n<p><code>Get-AzResource -ResourceGroupName 'MyResourceGroup' -ResourceType 'Microsoft.OpenAI\/workspaces'<\/code><\/p>\n\n\n\n<p>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!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If haven&#8217;t been living under a rock, you know that Azure OpenAI is a powerful tool that brings the cutting-edge capabilities of OpenAI&#8217;s models to the cloud, offering scalability, reliability, and integration with Azure&#8217;s vast ecosystem. Because I am who I am we will use PowerShell to setup our Azure OpenAI instance. Whether you&#8217;re automating &hellip; <a href=\"https:\/\/draith.com\/?p=649\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Setting up Azure OpenAI with PowerShell&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[26,4,16],"class_list":["post-649","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-ai","tag-azure","tag-powershell"],"_links":{"self":[{"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts\/649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=649"}],"version-history":[{"count":1,"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts\/649\/revisions"}],"predecessor-version":[{"id":650,"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts\/649\/revisions\/650"}],"wp:attachment":[{"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}