Putting some technologies together as a prototype for my next project.
- Serverless - Azure Functions with a consumption plan
- NoSQL - CosmosDB with a MongoDB interface
- Cloud security - Azure Key Vault to encrypt and decrypt sensitive data, as well for getting secrets
- Infrastructure-as-code - Terraform
Check the infrastructure section below to create the Azure resources.
Requirements:
- Azure Functions Core Tools
- Terraform CLI
Setup:
# set the variables in this file
cp local.settings.development.json local.settings.json
# download dependencies
python3 -m venv env
. env/bin/activate
pip install -r requirements.txt
Start Functions locally:
func start
Functions:
# Load questions
curl localhost:7071/api/LoadQuestions
# Post answers
curl --data '@shared_code/answers.json' http://localhost:7071/api/PostAnswers
#Get answers
curl http://localhost:7071/api/GetAnswers?id=participant@mail.com
az login
terraform init
terraform plan
terraform apply -auto-approve
Extra steps for local development.
Create the app registration:
az ad app create --display-name myproj888 --password '<STRONG_SECRET>'
Add the app credentials to local.settings.json
.
In the Key Vault add a Access Policy
for the app with KEY operations Get
, Decrypt
and Encrypt
Azure Functions Python developer guide