A pattern that showcases how to use AI Document Intelligence and document summarization
- AI Document Intelligence
- Azure OpenAI
- Azure Functions
You have two options for using this demo: you can either set it up locally on your machine or use GitHub Codespaces with devcontainers.
You can develop this demo locally on your own machine. Here's a simple guide to help you get started:
- Clone the repository to your local machine.
- Open the repository in your preferred code editor.
- Ensure that you have the necessary software and libraries installed. You will need the .NET 7 SDK, Azure Functions Core Tools, and Azure CLI.
- Build and test the application locally using Azure Functions.
Alternatively, you can use GitHub Codespaces with devcontainers. This method allows you to use a pre-configured development environment and avoids the need to install anything on your local machine.
Here's a simple guide to get you started:
- Navigate to the repository on GitHub.
- Click on the 'Code' button and then select 'Open with Codespaces'.
- Click on the '+ New codespace' button.
- After a few moments, your codespace should be ready and you'll be taken to an online version of Visual Studio Code.
This codespace is a full-fledged development environment and you can write and run your code just like you would on your local machine. The devcontainer configuration in the repository sets up all the necessary software and libraries for you.
Please follow these steps to set up your environment variables:
- Copy the provided
local.settings.json.example
aslocal.settings.json
file. - Edit the
local.settings.json
and change the following:
- Replace
{document-intelligence}
with your Document Intelligence instance's name. - Replace the first
{key}
with your Document Intelligence key. - Replace
{openai}
with your OpenAI instance's name. - Replace the second
{key}
with your OpenAI key. - Replace both instances of
{deployment-name}
with your deployment's name.
This file will now be used to configure your environment variables.
Currently, Azure CLI doesn't support creating an Azure OpenAI instance directly. You'll need to use the OpenAI API.
To interact with OpenAI GPT-3.5 Turbo, sign up on the OpenAI website, get your API keys, and use them in your application following the OpenAI API documentation.
As of now, Azure CLI does not support the direct creation of AI Document Intelligence resources.
You can create and manage AI Document Intelligence resources using the Azure portal, REST APIs, or SDKs. Please refer to the official Azure AI Document Intelligence documentation for detailed steps.
First, setup your environment variables
export SUBSCRIPTION_ID=VALUE
export RESOURCE_GROUP_NAME=VALUE
export LOCATION=VALUE
export STORAGE_ACCOUNT_NAME=VALUE
export FUNCTION_APP_NAME=VALUE
Login to Azure and set your subscription:
az login
az account set --subscription ${SUBSCRIPTION_ID}
Next, create a resource group, a storage account, and an Azure Functions app:
az group create --name ${RESOURCE_GROUP_NAME} --location $LOCATION
az storage account create \
--name ${STORAGE_ACCOUNT_NAME} \
--location ${LOCATION} \
--resource-group ${RESOURCE_GROUP_NAME} \
--sku Standard_LRS
az functionapp create \
--resource-group ${RESOURCE_GROUP_NAME} \
--consumption-plan-location ${LOCATION} \
--runtime dotnet-isolated \
--functions-version 4 \
--name ${FUNCTION_APP_NAME} \
--storage-account ${STORAGE_ACCOUNT_NAME}
Now you're ready to deploy your code to Azure Functions. You can use the Azure Function CLI for this.
func azure functionapp publish ${FUNCTION_APP_NAME}
This will upload the contents of the publish
directory to your Function App in Azure.
To remove the Azure Functions, run the following command:
az group delete --name ${RESOURCE_GROUP_NAME}