This repo has an Azure Function app that uses managed identity to save conversation history in Cosmos DB and works with Semantic Kernel.
-
✅ Allow Remote Build
- Navigate to your Function App → Configuration → Check
SCM_DO_BUILD_DURING_DEPLOYMENT=true
- Command:
az functionapp config appsettings set -g <resource-group> -n <app-name> --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true
- Navigate to your Function App → Configuration → Check
-
🚀 Deploy with Remote Build
⚠️ Note: Basic/Free Tier App Service Plan does not support remote builds, especially for Python/Azure Functions.- Command:
func azure functionapp publish <app-name> --build remote
- Assign Cosmos DB Data Plane Role to resources: Data Plane Roles (❌ Not Visible in Azure Portal IAM). These roles are part of Cosmos DB’s native RBAC system, which is separate from Azure RBAC. Microsoft has not yet integrated these into the IAM UI, so they must be managed via the console:
- You need to have 2 principal IDs: one for your local development via signed-user, and another for your function app principal ID.
- 🧹 Optional: Clear Azure Account
az account clear
- 🔍 Get Your Principal IDs
- Current Logged-in User Principal ID:
az login --tenant TENANT_ID az ad signed-in-user show
- Azure Function App's Principal ID:
OR navigate to
az functionapp identity show \ --name <your-function-app-name> \ --resource-group <your-resource-group> \ --query principalId \ --output tsv
Azure portal > Function App > Identity > System Assigned > Status: On > <Your Principal ID>
- 📜 Optional: Cosmos DB Data Plane Role Definition ID
- The command will return
00000000-0000-0000-0000-000000000002
.
az cosmosdb sql role definition list \ --account-name <your-cosmosdb-account-name> \ --resource-group <your-resource-group>
- The command will return
- 🛠️ Assign Cosmos DB Data Plane Role to Principal IDs
az cosmosdb sql role assignment create \ --account-name <your-cosmosdb-account-name> \ --resource-group <your-resource-group> \ --scope "/" \ --principal-id <your-managed-identity-object-id> \ --role-definition-id "00000000-0000-0000-0000-000000000002"
- ✅ Verify Role Assignment
az cosmosdb sql role assignment list \ --account-name <your-cosmosdb-account-name> \ --resource-group <your-resource-group>
- 🚀 Deploy Your Function App
func azure functionapp publish <your-function-app-name> --python
- 🛑 To resolve FUNCTIONS_WORKER_RUNTIME invalid error: Error: The following app setting (Site.SiteConfig.AppSettings.FUNCTIONS_WORKER_RUNTIME) for Flex Consumption sites is invalid. Please remove or rename it before retrying.: Do not add
"FUNCTIONS_WORKER_RUNTIME" : "python"
inlocal.settings.json
. - 🔑 AzureWebJobsStorage: Assign the “Storage Blob Data Contributor” role to Azure Functions.
- 📦 Dependency Management: Azure Functions does not natively support Poetry for dependency management. It expects a
requirements.txt
file to install Python dependencies during deployment. The command for convertingpoetry.toml
torequirements.txt
poetry export -f requirements.txt --without-hashes -o requirements.txt