mvn archetype:generate -DarchetypeGroupId=com.microsoft.azure -DarchetypeArtifactId=azure-functions-archetype -DjavaVersion=11
How to install Azure CLI https://learn.microsoft.com/en-us/cli/azure/install-azure-cli
https://developer.hashicorp.com/terraform/tutorials/azure-get-started
https://developer.hashicorp.com/terraform/tutorials/azure-get-started/install-cli
Create file with .auto.tfvars
extension in src/main/tf
directory, example src/main/tf/myenv.auto.tfvars
Set variable in this file like in this example below
azure_subscription_id = "your azure subscription id"
azure_tenant_id = "your azure tenant id"
resource_group_name = "resource group in which resources will be created"
project_name = "name used for resource that need to have unique name"
function_storage_account = "name used for function app storage account that need to have unique name"
project_unique_id = 123456 # additional identifier for uniqueness
notification_alert_email = "your email"
cd src/main/tf
terraform init
cd src/main/tf
terraform plan
terraform apply
export FUNC_APP_PLAN=$(cd src/main/tf && terraform state show azurerm_service_plan.this |grep name |grep -v resource_group_name |grep -v sku_name |cut -d "=" -f2 |xargs |tr -d '[:space:]')
export FUNC_APP=$(cd src/main/tf && terraform state show azurerm_windows_function_app.this |grep name |grep -v hostname |grep -v resource_group_name |grep -v storage_account_name |head -n1 |cut -d "=" -f2 |xargs |tr -d '[:space:]')
export RG_NAME=$(cat src/main/tf/myenv.auto.tfvars |grep resource_group_name |cut -d "=" -f2 |xargs |tr -d '[:space:]')
https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local
mvn clean package
Run locally
mvn azure-functions:run
Generate samples
./generate_samples.sh http://localhost:7071/api/post-observations-v1 "ignore"
az login
mvn clean package azure-functions:deploy -Dapp.name=$FUNC_APP -Dapp.plan.name=$FUNC_APP_PLAN -Dapp.resource.group=$RG_NAME
az functionapp keys list --resource-group ${RG_NAME} --name ${FUNC_APP}
az functionapp keys set -g ${RG_NAME} -n ${FUNC_APP} --key-type functionKeys --key-name MyKeyName --key-value MyKeyValue
az functionapp function keys list -g ${RG_NAME} -n ${FUNC_APP} --function-name get-latest-observations-v1
az functionapp function keys list -g ${RG_NAME} -n ${FUNC_APP} --function-name post-observations-v1
See plan
az appservice plan show -n $FUNC_APP_PLAN -g $RG_NAME
See function
az functionapp function show -g ${RG_NAME} -n ${FUNC_APP} --function-name get-latest-observations-v1
List function endpoints
az functionapp function show -g ${RG_NAME} -n ${FUNC_APP} --function-name get-latest-observations-v1 |jq -r '.invokeUrlTemplate'
az functionapp function show -g ${RG_NAME} -n ${FUNC_APP} --function-name get-latest-observation-v1 |jq -r '.invokeUrlTemplate'
az functionapp function show -g ${RG_NAME} -n ${FUNC_APP} --function-name get-extremes-v1 |jq -r '.invokeUrlTemplate'
az functionapp function show -g ${RG_NAME} -n ${FUNC_APP} --function-name post-observations-v1
See deployment logs
az functionapp log deployment list -n $FUNC_APP -g $RG_NAME
func azure functionapp logstream ${FUNC_APP}
funcAppId=$(az resource show -g $RG_NAME -n $FUNC_APP --resource-type 'Microsoft.Web/sites' |jq -r '.id')
Sample metrics
az monitor metrics list --resource $funcAppId --metrics "MemoryWorkingSet"
az monitor metrics list --resource $funcAppId --metrics "Requests"
az monitor metrics list --resource $funcAppId --metrics "Http2xx"
az group list --query "[?name == '$RG_NAME']"
az group delete -g $RG_NAME
Find API key and POST function endpoint
apiKey=$(az functionapp keys list --resource-group ${RG_NAME} --name ${FUNC_APP} |jq -r '.functionKeys.default')
postUrl=$(az functionapp function show -g ${RG_NAME} -n ${FUNC_APP} --function-name post-observations-v1 |jq -r '.invokeUrlTemplate')
Run generator
./generate_samples.sh "$postUrl" "$apiKey"
https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions
mvn help:evaluate