This guide walks you through deploying a minimalistic Flask application with Azure OpenAI's GPT integration to an Azure Web App.
- In Azure OpenAI / AI Studio, deploy the required GPT-x model;
- Take note of Azire OpenAI resource's endpoint, GPT model's deployment name and the API version you plan to use.
- In Azure, create a new Web app and select Python as your target language platform;
- In the Web app's Environment Variables settings, create the following variables and set them to the values collected from Step 1:
AZURE_OPENAI_API_BASE
,AZURE_OPENAI_API_DEPLOY
andAZURE_OPENAI_API_VERSION
; - In the Web app's Environment Variables settings, create the variable
SCM_DO_BUILD_DURING_DEPLOYMENT
and set its value to "true";
Note: The SCM_DO_BUILD_DURING_DEPLOYMENT setting ensures that the Web app downloads required Python packages, listed in the provided requirements.txt file.
- In the Web app's Identity settings, set the status of system-assigned managed identity to ON;
Note: this demo shows how to authenticate with a managed identity. You can find implementation details for other potential options here.
- In Azure OpenAI's Access Control (IAM) settings, assign the Web app's managed identity the Cognitive Services OpenAI User role.
- ZIP the provided
app.py
,requirements.txt
and the content of thestatic
andtemplates
folders (4 files in total); - Deploy your ZIP file with the following Azure CLI command. Ensure you use the correct Resource Group, Web App and ZIP file names:
az webapp deploy --resource-group <Web_App_RG> --name <Web_App_Name> --src-path <Source_ZIP_file>