Thanks to visit codestin.com
Credit goes to github.com

Skip to content

amaudy/tfazfunc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello Azure function (Python)

This is a simple Azure function written in Python.

Deployment Guide: Azure Functions to UK South Region

Prerequisites

  • Azure CLI installed and configured
  • Azure subscription
  • Python 3.8 or later
  • Git (optional, for version control)

Project Structure

Ensure your project has the following structure before deployment:

learnazfunctions/
├── host.json                 # Host configuration file
├── requirements.txt          # Python dependencies
└── hello_world/              # Function directory
    ├── __init__.py           # Function code
    └── function.json         # Function configuration

Deployment Steps

1. Login to Azure

az login

2. Create a Resource Group in UK South

az group create --name helloazfuncuks-rg --location uksouth

3. Create a Storage Account

az storage account create \
  --name helloazfuncukssa \
  --location uksouth \
  --resource-group helloazfuncuks-rg \
  --sku Standard_LRS

4. Create a Function App

az functionapp create \
  --name helloazfuncuks \
  --storage-account helloazfuncukssa \
  --consumption-plan-location uksouth \
  --resource-group helloazfuncuks-rg \
  --os-type Linux \
  --runtime python \
  --runtime-version 3.12 \
  --functions-version 4

5. Deploy the Function App

From the root directory of your project:

az functionapp deployment source config-zip \
  --resource-group helloazfuncuks-rg \
  --name helloazfuncuks \
  --src ./deployment.zip

Note: You need to create the deployment.zip first. You can do this with:

# Navigate to your function app directory
cd /path/to/learnazfunctions

# Create a deployment package
zip -r deployment.zip . -x "*.git*" "*.vscode*" "*.venv*" "__pycache__*"

6. Verify Deployment

# Get the function URL
az functionapp function show \
  --name helloazfuncuks \
  --resource-group helloazfuncuks-rg \
  --function-name hello_world \
  --query invokeUrlTemplate \
  --output tsv

Test the function by visiting the URL in your browser or using curl.

Troubleshooting

  • Check function logs:

    az functionapp logs tail --name helloazfuncuks --resource-group helloazfuncuks-rg
  • If deployment fails, ensure all required files are present and correctly formatted

  • Verify your Python version is compatible with Azure Functions

  • Check for any dependency issues in requirements.txt

Cleanup

To remove all resources when no longer needed:

az group delete --name helloazfuncuks-rg --yes

Important Notes

  • The storage account name must be globally unique
  • Function names are case-sensitive
  • UK South region code is "uksouth"
  • Default authentication level is "function" which requires a function key

Additional Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published