This project is a sample Azure Function App implemented in Python, demonstrating how to build and deploy an HTTP-triggered function using Azure Functions and Terraform for infrastructure provisioning.
- Azure Function: A Python HTTP-triggered function named
HttpFunctionthat returns a personalized greeting message. It accepts anameparameter via query string or JSON request body. - Infrastructure as Code: Terraform scripts to provision the necessary Azure resources including a resource group, storage account, storage containers, and diagnostic storage tables.
- Testing Client: A simple Python script to invoke the Azure Function locally or remotely for testing.
- Azure CLI
- Terraform
- Python 3.8 or later
- Azure Functions Core Tools (for local development)
- An Azure subscription
git clone <repository-url>
cd azure-sample-function-appTerraform scripts are located in the root directory.
terraform init
terraform applyThis will create:
- Resource group
rg-funcapp-test - Storage account and containers needed for the Function App
- Storage share and diagnostic tables
Navigate to the src directory and install dependencies:
cd src
pip install -r requirements.txtEnsure Azure Functions Core Tools is installed. Run the function app:
func startThe function will be available at:
http://localhost:7071/api/HttpFunction
You can test with a query parameter, e.g.:
http://localhost:7071/api/HttpFunction?name=Artem
Follow Azure Functions deployment best practices (not included in this repo). You can use Azure CLI or VS Code Azure Functions extension to deploy.
The function responds with a greeting message:
- If
nameis provided in query string or JSON body, it returns:
"Hello, {name}. This HTTP triggered function executed successfully." - Otherwise, it returns a generic success message.
The src/test_main.py script acts as a client to test the function locally or remotely.
Usage:
python src/test_main.py -localThis calls the local function endpoint. To test the deployed Azure function, omit the -local flag. Update the URL and function key in the script as needed.
.
├── main.tf # Terraform main configuration
├── provider.tf # Terraform provider configuration
├── src/
│ ├── function_app.py # Azure Function app implementation
│ ├── host.json # Azure Functions runtime configuration
│ ├── requirements.txt # Python dependencies
│ └── test_main.py # Test client script
- The Terraform storage account name and resource group are hardcoded and may require modification for uniqueness.
- The function uses Azure Functions Python worker managed by the platform; do not manually manage
azure-functions-worker. - The project uses Azure Functions extension bundle version 4.x.
MIT License (if applicable)