Home NewsX Easily deploy an Azure Open AI instance with Documents

Easily deploy an Azure Open AI instance with Documents

by info.odysseyx@gmail.com
0 comment 11 views


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.

Warneral_0-1722520695765.png

Next, go to All Services and search for Open AI to deploy an Open AI instance.


Berneral_1-1722520779511.png

Create an instance by placing it in the same resource group. Accept all defaults and press Next until the resources are deployed.

Warner_0-1722520962870.png

Berneral_1-1722521203205.png

Click “Go to Resources” Activate the managed ID assigned by the system. Copy the object ID of the managed ID generated for later use.

6.jpg

Step 2: Set up an Azure Search index

We’re looking at AI search across all services.

Bernal_0-1722596660628.png


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.


Berneral_11-1722598573430.png

Bernal_2-1722596843213.png

Click “Go to Resources” and ensure that Semantic Ranker shows “Selected Plans”.

Bernal_6-1722597420999.png

To enable RBAC and API key usage, set up both keys.

Bernal_7-1722597558488.png

Activate the managed ID assigned by the system. Copy the object ID of the managed ID generated for later use.

Warner_1-1722600466197.png

Step 3: Create a storage account

In all services we search for storage

Bernal_8-1722597867511.png

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.

Warneral_9-1722598070496.png

Bernal_10-1722598471457.png

Go to Resources and click on Containers.

Berneral_12-1722598665324.png

Create a new container to store knowledge articles or upload files.

az ad signed-in-user show --query id -o tsv​

Berneral_13-1722598789048.png

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”

Berneral_3-1722601190977.png

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.

Bernal_0-1722599423381.png

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.

Warneral_2-1722600829768.png

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”.

Bernal_5-1722776864361.png

On the landing page, click Deploy and Deploy Model.

Warner_6-1722601456854.png

We will deploy two models: the base “text-embedding-ada-002” and the “gpt-4o” model. Let’s start with text-embedding-ada-002.

image.png

Berneral_15-1722602842388.png

Next, we deploy the GPT-4o model.

Warneral_9-1722601834303.png

Berneral_10-1722601889392.png

Both distributions should now be visible.

Berneral_18-1722602973734.png

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.

Berneral_14-1722602497433.png

Berneral_19-1722603046983.png

We will use hybrid + semantic search.

Berneral_20-1722603087865.png

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.

Berneral_21-1722603138779.png

Berneral_22-1722603199130.png

You can see your data being processed and indexed.

Bernal_0-1722603321334.png

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”.

Bernal_1-1722603377394.png

Here you can enter all the details. If this is your second or third deployment, you can also select “Update existing web app”.

Berneral_2-1722603468790.png

To verify that your app is deployed, you can go back to the Azure portal and look at your resource group under Deployments.

Bernal_3-1722603560137.png

Once your website is ready, you can navigate to your web app or find your new web app in your resource group.

Bernal_4-1722776850654.pngWarner_0-1722604005450.png

Now we can finally enjoy our newly released large-scale language models.

Warner_0-1722776508865.png

Warner_1-1722776560091.png

Berneral_2-1722776589889.png

Sometimes this can happen

Bernal_3-1722776692664.png

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.

image.png

image.png

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

You may also like

Leave a Comment

Our Company

Welcome to OdysseyX, your one-stop destination for the latest news and opportunities across various domains.

Newsletter

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

Laest News

@2024 – All Right Reserved. Designed and Developed by OdysseyX