This example builds and deploys a custom Azure function container image to a Linux App Service plan.
The Bicep template also deploys the following resources:
- Azure SQL Server
- Azure SQL Database
- Virtual Network and subnets
- Storage Account
- Azure Container Registry
- Application Insights
- User managed identity.
Optionally, if the ./deploy.sh script is passed the '-p' flag the SQL Server, Azure Container Registry and Storage Account will each be provisioned behind their own Private Endpoints.
- local Bash or Azure Cloud shell instance
- Azure CLI
- create a file ./deploy/.env containing 'SQL_ADMIN_USER_PASSWORD' variable name and value contents show below
NOTE: double quotes are required around the password value
SQL_ADMIN_USER_PASSWORD="<your password>"
- run the deployment script
$ cd ./deploy
$ ./deploy.sh
- optional: add the '-p' flag to deploy the Azure SQL Database, Azure Container Registry and Azure Function storage account behind private endpoints.
$ cd ./deploy
$ ./deploy.sh -p
- optional: add the '-s' flag to skip the container image build
$ cd ./deploy
$ ./deploy.sh -s
- optional: add the both flags to skip the container image build and deploy private endpoints
$ cd ./deploy
$ ./deploy.sh -s -p
- the function FQDN will be output to the console once the deployment completes. Add the value to an environment variable named 'FUNCTION_FQDN'
$ FUNCTION_FQDN=<function fqdn>
- add new todo items
$ curl https://$FUNCTION_FQDN/api/todos -X POST -d '{"description":"feed the dogs"}'
$ curl https://$FUNCTION_FQDN/api/todos -X POST -d '{"description":"get milk"}'
$ curl https://$FUNCTION_FQDN/api/todos -X POST -d '{"description":"walk the dogs"}'
- display all todo items
$ curl https://$FUNCTION_FQDN/api/todos
- complete a todo item
$ curl https://$FUNCTION_FQDN/api/todos/complete/1 -X PATCH
- get completed todo items
$ curl https://$FUNCTION_FQDN/api/todos/completed
- get incomplete todo items
$ curl https://$FUNCTION_FQDN/api/todos/incomplete
- update todo item
$ curl https://$FUNCTION_FQDN/api/todos/2 -X PATCH -d '{"description":"get chocolate"}'
- delete todo item
$ curl https://$FUNCTION_FQDN/api/todos/1 -X DELETE
- display all todo items
$ curl https://$FUNCTION_FQDN/api/todos