This is an old revision of the document!
Prerequisites
Install Azure CLI # Windows curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# macOS brew install azure-cli
# Or download from: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
Install Azure Functions Core Tools
# Windows (via npm) npm install -g azure-functions-core-tools@4 --unsafe-perm true
# macOS brew tap azure/functions brew install azure-functions-core-tools@4
# Linux curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-$(lsb_release -cs)-prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list' sudo apt-get update sudo apt-get install azure-functions-core-tools-4
Step 1: Login to Azure
az login Step 2: Set Your Subscription (if you have multiple) bash# List subscriptions az account list --output table # Set active subscription az account set --subscription "Your-Subscription-Name-Or-ID"
Step 3: Create Resource Group (if needed) bash
az group create --name myResourceGroup --location eastus
Step 4: Create Storage Account (for Function App) bash
az storage account create \ --name myfunctionstorageacct \ --location eastus \ --resource-group myResourceGroup \ --sku Standard_LRS
Step 5: Create Function App bash
az functionapp create \ --resource-group myResourceGroup \ --consumption-plan-location eastus \ --runtime python \ --runtime-version 3.9 \ --functions-version 4 \ --name myFaceBlurFunctionApp \ --storage-account myfunctionstorageacct \ --os-type linux
Step 6: Prepare Your Project Structure Create the following folder structure: face-blur-function/ ├── requirements.txt ├── host.json ├── local.settings.json ├── FaceBlurTimer/ │ ├── init.py │ └── function.json └── shared/
└── face_blur_processor.py
Step 7: Create Project Files requirements.txt
txtazure-functions azure-storage-blob requests python-dotenv Pillow schedule
host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 3.0.0)"
},
"functionTimeout": "00:10:00"
}
local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "your_function_storage_connection_string",
"FUNCTIONS_WORKER_RUNTIME": "python",
"AZURE_STORAGE_CONNECTION_STRING": "your_blob_storage_connection_string",
"AZURE_CONTAINER_NAME": "your_source_container_name",
"WEBAPP_URL": "https://your-webapp.com/blur",
"WEBAPP_TIMEOUT": "60"
}
}
<code>
FaceBlurTimer/function.json
<code>
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "mytimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 0 * * * *"
}
]
}
Step 8: Set Application Settings
# Set your environment variables az functionapp config appsettings set \ --name myFaceBlurFunctionApp \ --resource-group myResourceGroup \ --settings \ "AZURE_STORAGE_CONNECTION_STRING=your_blob_storage_connection_string" \ "AZURE_CONTAINER_NAME=your_source_container_name" \ "WEBAPP_URL=https://your-webapp.com/blur" \ "WEBAPP_TIMEOUT=60"
Step 9: Initialize Function Project Locally
# Create project directory mkdir face-blur-function cd face-blur-function # Initialize function project func init --python
Step 10: Create Timer Function
func new --name FaceBlurTimer --template "Timer trigger" <code> Step 11: Deploy to Azure <code> # Deploy the function func azure functionapp publish myFaceBlurFunctionApp
Alternative: Deploy using Azure CLI (Zip Deploy) If you prefer to deploy using zip:
Create deployment package zip -r deployment.zip .
# Deploy using az cli
az functionapp deployment source config-zip \ --resource-group myResourceGroup \ --name myFaceBlurFunctionApp \ --src deployment.zip