Easily deploy an Azure Open AI instance with Documents by info.odysseyx@gmail.com August 30, 2024 written by info.odysseyx@gmail.com August 30, 2024 0 comment 6 views 6 introduction Deploying an Azure OpenAI instance integrated with a search index and storage account can greatly enhance the functionality of your application. This guide will walk you through the process step by step. Prerequisites Active Azure Subscription Azure CLI installed Basic understanding of Azure services Step 1: Set up an Azure OpenAI instance Create a resource group. In our case, we called it DeployOpenAI. Next, go to All Services and search for Open AI to deploy an Open AI instance. Create an instance by placing it in the same resource group. Accept all defaults and press Next until the resources are deployed. Click “Go to Resources” Activate the managed ID assigned by the system. Copy the object ID of the managed ID generated for later use. Step 2: Set up an Azure Search index We’re looking at AI search across all services. This example uses the Basic pricing tier and a different region. We use the Basic pricing tier because it supports managed identities. At the time of publishing this article, Semantic Ranker is only available in some regions, so we used the South of England region. Click “Go to Resources” and ensure that Semantic Ranker shows “Selected Plans”. To enable RBAC and API key usage, set up both keys. Activate the managed ID assigned by the system. Copy the object ID of the managed ID generated for later use. Step 3: Create a storage account In all services we search for storage Technically you can create the storage account anywhere, but I prefer it close to my search index, so I choose UK South as the region. Then I adjust the redundancy to LRS to save on costs. You can keep the default settings for the rest of the storage accounts and move on to the next one until the resources are created. Go to Resources and click on Containers. Create a new container to store knowledge articles or upload files. az ad signed-in-user show --query id -o tsv Upload the file that you want the language model to be able to interpret later. We will upload the Microsoft Azure SLA document in PDF format. The supported formats are: “Txt, .md, .html, .docx, .pptx, and .pdf” Step 4: Authorization Permissions can sometimes be confusing, especially if you don’t normally work with Azure. Copy the script from my GitHub repository –> RallTheory/OpenAIBYODPermissions/OpenAIStudioPermissionsRequired.sh in main · WernerRall147/RallTheo… # Variables resourceGroup="#TODO" userObjectId="#TODO" managedIdentityObjectId1="#TODO" managedIdentityObjectId2="#TODO" subscriptionId="#TODO" # Assign Cognitive Services OpenAI Contributor az role assignment create --assignee $userObjectId --role "Cognitive Services OpenAI Contributor" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup az role assignment create --assignee $managedIdentityObjectId1 --role "Cognitive Services OpenAI Contributor" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup az role assignment create --assignee $managedIdentityObjectId2 --role "Cognitive Services OpenAI Contributor" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup # Assign Cognitive Services Contributor az role assignment create --assignee $userObjectId --role "Cognitive Services Contributor" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup az role assignment create --assignee $managedIdentityObjectId1 --role "Cognitive Services Contributor" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup az role assignment create --assignee $managedIdentityObjectId2 --role "Cognitive Services Contributor" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup # Assign Search Index Data Reader az role assignment create --assignee $userObjectId --role "Search Index Data Reader" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup az role assignment create --assignee $managedIdentityObjectId1 --role "Search Index Data Reader" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup az role assignment create --assignee $managedIdentityObjectId2 --role "Search Index Data Reader" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup # Assign Storage Blob Data Contributor az role assignment create --assignee $userObjectId --role "Storage Blob Data Contributor" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup az role assignment create --assignee $managedIdentityObjectId1 --role "Storage Blob Data Contributor" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup az role assignment create --assignee $managedIdentityObjectId2 --role "Storage Blob Data Contributor" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup # Assign Search Service Contributor az role assignment create --assignee $userObjectId --role "Search Service Contributor" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup az role assignment create --assignee $managedIdentityObjectId1 --role "Search Service Contributor" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup az role assignment create --assignee $managedIdentityObjectId2 --role "Search Service Contributor" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroup Replace only the variables section with #TODO labels. The two managed identity objects you copied in the previous step. To get your unique user object ID, you can run the script below by running Azure Cloud Shell. az ad signed-in-user show --query id -o tsv Now our variable should look something like this (I’ve hidden some characters): # Variables resourceGroup="DeployOpenAI" userObjectId="6167fxxxxxxxxxxxxxxxxxx" managedIdentityObjectId1="f24cbcxxxxxxxxxxxxxxxxxxx" managedIdentityObjectId2="542bxxxxxxxxxxxxxxxxxxxxxx" subscriptionId="2910xxxxxxxxxxxxxxxxxxxxxxxxx" Now you are ready to apply permissions. Copy the entire script, including the variables section, and paste it into Azure Cloud Shell. Then press Enter. The output should look similar to the following. If all permissions are applied successfully, you should not encounter any issues in Open AI Studio. Step 5: Open AI Studio Deployment Go to Open AI Distribution and click “Go to Azure OpenAI Studio”. On the landing page, click Deploy and Deploy Model. We will deploy two models: the base “text-embedding-ada-002” and the “gpt-4o” model. Let’s start with text-embedding-ada-002. Next, we deploy the GPT-4o model. Both distributions should now be visible. Now you need to load data from your Storage Account to your AI Search Index. You can do this by clicking “Add your data” in Chat. We will use hybrid + semantic search. Click Next in System Assigned Managed Identity. If the permissions were applied correctly, there should be no error here and you can continue with Save and Close. You can see your data being processed and indexed. Finally, we need to create a deployment for our web app so that we can interact with all of these parts. Let’s go to the chat and click “Deploy to Web App”. Here you can enter all the details. If this is your second or third deployment, you can also select “Update existing web app”. To verify that your app is deployed, you can go back to the Azure portal and look at your resource group under Deployments. Once your website is ready, you can navigate to your web app or find your new web app in your resource group. Now we can finally enjoy our newly released large-scale language models. Sometimes this can happen To resolve this issue, you can do one of the following: 1. Increase the model rate limit or request more quota. You may need to redeploy to your existing web app. If the error persists, you can deploy another model that comes with more quota by default or request quota for the model you need from Azure Support. 2. Reduce the size of your document by converting it to an easier format, such as “.txt” or “md”. Converting file formats like PDF to TXT can help you significantly reduce token usage when working with Azure OpenAI or other text-based AI models. In this blog I have chosen to deploy gpt-4 with a different model to help us solve our problem. After adding some quotas and re-deploying the app with gpt-4, I am now getting better response. I hope you find this guide helpful. disclaimer The sample script is not supported by any Microsoft standard support program or service. The sample script or Power BI dashboard is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties, including but not limited to the implied warranties of merchantability or fitness for a particular purpose. The entire risk arising out of the use or performance of the sample script and documentation remains with you. In no event shall Microsoft, the authors, or anyone else involved in the creation, production, or delivery of the script or Power BI dashboard be liable for any damages whatsoever (including but not limited to damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample script or documentation, even if Microsoft has been advised of the possibility of such damages. This blog post was created with the assistance of Generation AI. Source link Share 0 FacebookTwitterPinterestEmail info.odysseyx@gmail.com previous post What’s New in Copilot | August 2024 next post Meet a recent Microsoft Learn Student Ambassador graduate Hrittik Roy You may also like From Zero to Hero: Building Your First Voice Bot with GPT-4o Real-Time API using... October 12, 2024 A Guide to Responsible Synthetic Data Creation October 12, 2024 Capacity Template – MGDC for SharePoint October 11, 2024 Using Azure NetApp Files (ANF) for data- and logfiles for Microsoft SQL Server in... October 11, 2024 Microsoft Community – Do you love stickers?! Do you want to be a part... October 11, 2024 Advanced Alerting Strategies for Azure Monitoring October 11, 2024 Leave a Comment Cancel Reply Save my name, email, and website in this browser for the next time I comment.