Open iMicknl opened 1 month ago
here is a cli script that might be useful. Probably needs to be cleaned up. Uses keys, rather than managed identities.
$PREFIX="ahpodcast" $SUFFIX="03"
$RESOURCE_GROUP_NAME="${PREFIX}demo${SUFFIX}" $LOCATION="westeurope" $FormRecognizerName="${PREFIX}formrecognizer${SUFFIX}" $SpeechName="${PREFIX}speech${SUFFIX}" $azureAIServiceName="${PREFIX}openai${SUFFIX}" $PODCAST_NAME="${PREFIX}generator${SUFFIX}" $OPENAILOCATION="swedencentral" $MODELDEPLOYMENTNAME="gpt-4o-deployment" $MODELNAME="gpt-4o" $MODELVERSION="2024-08-06" $AZURE_SPEECH_REGION="westeurope" $SKU="S0"
az group create --name $RESOURCE_GROUP_NAME --location $LOCATION
az cognitiveservices account create --name $FormRecognizerName
--resource-group $RESOURCE_GROUP_NAME --kind FormRecognizer
--sku $SKU --location $LOCATION
--yes
$FORMKEY=az cognitiveservices account keys list --name $FormRecognizerName
--resource-group $RESOURCE_GROUP_NAME `
--query key1 --output tsv
echo $FORMKEY
$FORMENDPOINT = az cognitiveservices account show --name $FormRecognizerName
--resource-group $RESOURCE_GROUP_NAME `
--query "properties.endpoint" --output tsv
echo $FORMENDPOINT
az cognitiveservices account create --name $SpeechName
--resource-group $RESOURCE_GROUP_NAME --kind SpeechServices
--sku $SKU --location $AZURE_SPEECH_REGION
--yes
$SPEECHKEY = az cognitiveservices account keys list --name $SpeechName
--resource-group $RESOURCE_GROUP_NAME `
--query key1 --output tsv
echo $SPEECHKEY
$SPEECHENDPOINT = az cognitiveservices account show --name $SpeechName
--resource-group $RESOURCE_GROUP_NAME `
--query "properties.endpoint" --output tsv
echo $SPEECHENDPOINT
$AZURE_SPEECH_RESOURCE_ID=az cognitiveservices account show --name $SpeechName --resource-group $RESOURCE_GROUP_NAME --query id --output tsv echo $AZURE_SPEECH_RESOURCE_ID
az cognitiveservices account create --name $azureAIServiceName
--resource-group $RESOURCE_GROUP_NAME --kind OpenAI
--sku $SKU --location $OPENAILOCATION
--yes
$OPENAIENDPOINT = az cognitiveservices account show --name $azureAIServiceName
--resource-group $RESOURCE_GROUP_NAME `
--query "properties.endpoint" --output tsv
echo $OPENAIENDPOINT
$OPENAIKEY = az cognitiveservices account keys list --name $azureAIServiceName
--resource-group $RESOURCE_GROUP_NAME `
--query key1 --output tsv
echo $OPENAIKEY
az cognitiveservices account deployment create --name $azureAIServiceName
--resource-group $RESOURCE_GROUP_NAME --model-format OpenAI --sku Standard
--model-name $MODELNAME --model-version $MODELVERSION `
--deployment-name $MODELDEPLOYMENTNAME --capacity 120
git clone https://github.com/iMicknl/azure-podcast-generator
cd azure-podcast-generator
az containerapp up --resource-group $RESOURCE_GROUP_NAME --name $PODCAST_NAME --location $LOCATION
--ingress external --target-port 9000 --source . --env-vars DOCUMENTINTELLIGENCE_ENDPOINT=$FORMENDPOINT
AZURE_OPENAI_ENDPOINT=$OPENAIENDPOINT AZURE_OPENAI_MODEL_DEPLOYMENT=$MODELDEPLOYMENTNAME
AZURE_SPEECH_RESOURCE_ID=$AZURE_SPEECH_RESOURCE_ID AZURE_SPEECH_REGION=$AZURE_SPEECH_REGION
DOCUMENTINTELLIGENCE_API_KEY=$FORMKEY AZURE_OPENAI_KEY=$OPENAIKEY
AZURE_SPEECH_KEY=$SPEECHKEY
az containerapp ingress sticky-sessions set --affinity sticky ` --name $PODCAST_NAME --resource-group $RESOURCE_GROUP_NAME
# Parameters
$PREFIX="ahpodcast"
$SUFFIX="03"
$RESOURCE_GROUP_NAME="${PREFIX}demo${SUFFIX}"
$LOCATION="westeurope"
$FormRecognizerName="${PREFIX}formrecognizer${SUFFIX}"
$SpeechName="${PREFIX}speech${SUFFIX}"
$azureAIServiceName="${PREFIX}openai${SUFFIX}"
$PODCAST_NAME="${PREFIX}generator${SUFFIX}"
$OPENAILOCATION="swedencentral"
$MODELDEPLOYMENTNAME="gpt-4o-deployment"
$MODELNAME="gpt-4o"
$MODELVERSION="2024-08-06"
$AZURE_SPEECH_REGION="westeurope"
$SKU="S0"
# Create resource group
az group create --name $RESOURCE_GROUP_NAME --location $LOCATION
# create a document intelligent resource in the resource group
az cognitiveservices account create `
--name $FormRecognizerName `
--resource-group $RESOURCE_GROUP_NAME `
--kind FormRecognizer `
--sku $SKU `
--location $LOCATION `
--yes
# Get the endpoint and key
$FORMKEY=az cognitiveservices account keys list `
--name $FormRecognizerName `
--resource-group $RESOURCE_GROUP_NAME `
--query key1 --output tsv
echo $FORMKEY
$FORMENDPOINT = az cognitiveservices account show `
--name $FormRecognizerName `
--resource-group $RESOURCE_GROUP_NAME `
--query "properties.endpoint" --output tsv
echo $FORMENDPOINT
# Output
# create an azure speech resource in the resource group
az cognitiveservices account create `
--name $SpeechName `
--resource-group $RESOURCE_GROUP_NAME `
--kind SpeechServices `
--sku $SKU `
--location $AZURE_SPEECH_REGION `
--yes
# Get the endpoint and key
$SPEECHKEY = az cognitiveservices account keys list `
--name $SpeechName `
--resource-group $RESOURCE_GROUP_NAME `
--query key1 --output tsv
echo $SPEECHKEY
$SPEECHENDPOINT = az cognitiveservices account show `
--name $SpeechName `
--resource-group $RESOURCE_GROUP_NAME `
--query "properties.endpoint" --output tsv
echo $SPEECHENDPOINT
# get the speech resource
$AZURE_SPEECH_RESOURCE_ID=az cognitiveservices account show --name $SpeechName --resource-group $RESOURCE_GROUP_NAME --query id --output tsv
echo $AZURE_SPEECH_RESOURCE_ID
az cognitiveservices account create `
--name $azureAIServiceName `
--resource-group $RESOURCE_GROUP_NAME `
--kind OpenAI `
--sku $SKU `
--location $OPENAILOCATION `
--yes
# Get the endpoint
$OPENAIENDPOINT = az cognitiveservices account show `
--name $azureAIServiceName `
--resource-group $RESOURCE_GROUP_NAME `
--query "properties.endpoint" --output tsv
echo $OPENAIENDPOINT
# Get the key
$OPENAIKEY = az cognitiveservices account keys list `
--name $azureAIServiceName `
--resource-group $RESOURCE_GROUP_NAME `
--query key1 --output tsv
echo $OPENAIKEY
az cognitiveservices account deployment create `
--name $azureAIServiceName `
--resource-group $RESOURCE_GROUP_NAME `
--model-format OpenAI --sku Standard `
--model-name $MODELNAME --model-version $MODELVERSION `
--deployment-name $MODELDEPLOYMENTNAME --capacity 120
git clone https://github.com/iMicknl/azure-podcast-generator
cd azure-podcast-generator
az containerapp up --resource-group $RESOURCE_GROUP_NAME `
--name $PODCAST_NAME --location $LOCATION `
--ingress external --target-port 9000 --source . `
--env-vars DOCUMENTINTELLIGENCE_ENDPOINT=$FORMENDPOINT `
AZURE_OPENAI_ENDPOINT=$OPENAIENDPOINT `
AZURE_OPENAI_MODEL_DEPLOYMENT=$MODELDEPLOYMENTNAME `
AZURE_SPEECH_RESOURCE_ID=$AZURE_SPEECH_RESOURCE_ID `
AZURE_SPEECH_REGION=$AZURE_SPEECH_REGION `
DOCUMENTINTELLIGENCE_API_KEY=$FORMKEY `
AZURE_OPENAI_KEY=$OPENAIKEY `
AZURE_SPEECH_KEY=$SPEECHKEY
az containerapp ingress sticky-sessions set --affinity sticky `
--name $PODCAST_NAME --resource-group $RESOURCE_GROUP_NAME
Add infra as code, leveraging the best practices like managed identity, to provide an easy way to run the application in your own environment.
Preferably in Bicep and using https://azure.github.io/Azure-Verified-Modules/.