Skip to content

Commit

Permalink
Fix custom connection provision, update location var in provision scr…
Browse files Browse the repository at this point in the history
…ipt, add deployment.sh, update docker image (#71)

* update deployment sku

* add support and chat endpoint to env and checks in notebook

* move chat questions up to the top

* add ai sdk eval notebook for contoso-chat

* add df as input

* Add deployment of pf to provision.sh

* update provision script to westus2 and gpt4t

* remove gpt4turbo

* updating gpt4 to 35 for testing

* revert changes

* fix gpt

* remove github env var

* add register model as promptflow

* update region

* change deployment name

* update deployment logic in provision script

* update endpoint name

* change to dynamic naming

* change names to random numbers

* update chat env to dockerfile

* revert chat deployment file

* split out deployment script

* move deployment script

* remove unused txt file

* add bicep changes for testing

* fix bicep to include metadata for connection
  • Loading branch information
cassiebreviu authored Feb 29, 2024
1 parent 314cedc commit cc2e808
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 15 deletions.
1 change: 0 additions & 1 deletion deployment/chat-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineDeployment.schema.json\
endpoint_name: contoso-chat-store
model: azureml:contoso-chat-model:1
# You can also specify model files path inline
# path: examples/flows/chat/basic-chat
Expand Down
1 change: 0 additions & 1 deletion deployment/chat-endpoint.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
$schema: https://azuremlschemas.azureedge.net/latest/managedOnlineEndpoint.schema.json
name: contoso-chat-store
auth_mode: key
43 changes: 43 additions & 0 deletions deployment/deployment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# get config.json
echo "Writing config.json file for PromptFlow usage..."
subscriptionId=$(az account show --query id -o tsv)
resourceGroupName=$(az group show --name $resourceGroupName --query name -o tsv)
mlProjectName=$(az deployment group show --name contchat --resource-group $resourceGroupName --query properties.outputs.mlproject_name.value -o tsv)

# create a random hash for the endpoint name all lowercase letters
endpointName="contoso-chat-$RANDOM"
# create a random hash for the deployment name
deploymentName="contoso-chat-$RANDOM"

echo "{\"subscription_id\": \"$subscriptionId\", \"resource_group\": \"$resourceGroupName\", \"workspace_name\": \"$mlProjectName\"}" > config.json
$(cat principal.txt) --secret-permissions get list

# register promptflow as model
echo "Registering PromptFlow as a model in Azure ML..."
az extension add -n ml -y
az ml model create --file deployment/chat-model.yaml -g $resourceGroupName -w $mlProjectName

# Deploy prompt flow
echo "Deploying PromptFlow to Azure ML..."
az ml online-endpoint create --file deployment/chat-endpoint.yaml -n $endpointName -g $resourceGroupName -w $mlProjectName

# Setup deployment
echo "Setting up deployment..."
az ml online-deployment create --file deployment/chat-deployment.yaml --name $deploymentName --endpoint-name $endpointName --all-traffic -g $resourceGroupName -w $mlProjectName
az ml online-endpoint show -n $endpointName -g $resourceGroupName -w $mlProjectName
az ml online-deployment get-logs --name $deploymentName --endpoint-name $endpointName -g $resourceGroupName -w $mlProjectName

# Read endpoint principal
echo "Reading endpoint principal..."
az ml online-endpoint show -n $endpointName -g $resourceGroupName -w $mlProjectName > endpoint.json
jq -r '.identity.principal_id' endpoint.json > principal.txt
echo "Principal is: $(cat principal.txt)"

#Assign Permission to Endpoint Principal
echo "Assigning permissions to Principal..."
az role assignment create --assignee $(cat principal.txt) --role "AzureML Data Scientist" --scope "/subscriptions/$subscription_id/resourcegroups/$resourceGroupName/providers/Microsoft.MachineLearningServices/workspaces/$mlProjectName"
az role assignment create --assignee $(cat principal.txt) --role "Azure Machine Learning Workspace Connection Secrets Reader" --scope "/subscriptions/$subscription_id/resourcegroups/$resourceGroupName/providers/Microsoft.MachineLearningServices/workspaces/$mlProjectName/onlineEndpoints/$endpointName"
# Get keyValueName from Azure ML
keyValueName=$(az ml online-endpoint show -n $endpointName -g $resourceGroupName -w $mlProjectName --query "identity.principal_id" -o tsv)
echo "assigning permissions to Principal to Key vault.."
az keyvault set-policy --name $keyValueName --resource-group $resourceGroupName --object-id
2 changes: 1 addition & 1 deletion deployment/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/azureml/promptflow/promptflow-runtime:latest
FROM mcr.microsoft.com/azureml/promptflow/promptflow-runtime-stable:latest
COPY requirements.txt requirements.txt
RUN python -m pip install --upgrade pip
RUN pip install -r requirements.txt
22 changes: 11 additions & 11 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,6 @@ resource appinsights 'microsoft.insights/components@2020-02-02' = {
}
}



/*
resource cosmosConnection 'Microsoft.MachineLearningServices/workspaces/connections@2023-10-01' = {
parent: mlProject
name: 'contoso-cosmos'
Expand All @@ -417,15 +414,18 @@ resource cosmosConnection 'Microsoft.MachineLearningServices/workspaces/connecti
credentials: {
keys: {
key: cosmos.listKeys().primaryMasterKey
endpoint: cosmos.properties.documentEndpoint
databaseId: 'contoso-outdoor'
containerId: 'customers'
}
}
}
metadata: {
endpoint: cosmos.properties.documentEndpoint
databaseId: 'contoso-outdoor'
containerId: 'customers'
'azureml.flow.connection_type': 'Custom'
'azureml.flow.module': 'promptflow.connections'

}
}
}
*/


resource storageAccounts_stcontosocha735868071044_name_default 'Microsoft.Storage/storageAccounts/blobServices@2023-01-01' = {
parent: storage
Expand Down Expand Up @@ -593,7 +593,7 @@ resource mlHub 'Microsoft.MachineLearningServices/workspaces@2023-08-01-preview'
v1LegacyMode: false
containerRegistry: containerRegistry.id
publicNetworkAccess: 'Enabled'
discoveryUrl: 'https://swedencentral.api.azureml.ms/discovery'
discoveryUrl: 'https://${location}.api.azureml.ms/discovery'
}

resource openaiDefaultEndpoint 'endpoints' = {
Expand Down Expand Up @@ -661,7 +661,7 @@ resource mlProject 'Microsoft.MachineLearningServices/workspaces@2023-10-01' = {
hbiWorkspace: false
v1LegacyMode: false
publicNetworkAccess: 'Enabled'
discoveryUrl: 'https://swedencentral.api.azureml.ms/discovery'
discoveryUrl: 'https://${location}.api.azureml.ms/discovery'
// most properties are not allowed for a project workspace: "Project workspace shouldn't define ..."
hubResourceId: mlHub.id
}
Expand Down
2 changes: 1 addition & 1 deletion provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ echo "COSMOS_KEY=$cosmosKey" >> .env
echo "Writing config.json file for PromptFlow usage..."
subscriptionId=$(az account show --query id -o tsv)
echo "{\"subscription_id\": \"$subscriptionId\", \"resource_group\": \"$resourceGroupName\", \"workspace_name\": \"$mlProjectName\"}" > config.json

echo "Provisioning complete!"

0 comments on commit cc2e808

Please sign in to comment.