Skip to content

uzairash/Azure_function_app_with_contianer_enviornment

Repository files navigation

Azure Function App with Docker

This project demonstrates how to create an Azure Function App using Python and Docker.

Prerequisites

Getting Started

1. Initialize the Function App

First, create a new Azure Function App project:

func init az_func_app_with_docker --python
cd az_func_app_with_docker

2. Create a New Function

Create a new HTTP-triggered function:

func new --name HelloWorld --template "HTTP trigger" --authlevel "anonymous"

3. Update the Function Code

Update the function code in function_app.py as needed.

4. Create a Dockerfile

Ensure you have a Dockerfile in the root of your project with the necessary content.

5. Build and Run the Docker Container

Build the Docker image:

docker build -t az-func-app .

Run the Docker container:

docker run -p 8080:80 az-func-app

6. Test the Function

You can test the function by navigating to http://localhost:8080/api/HelloWorld in your web browser or using a tool like curl:

curl http://localhost:8080/api/HelloWorld?name=Azure

You should see the response:

Hello, Azure. This HTTP triggered function executed successfully.

7. Deploy to Azure

Login to Azure:

az login

Create a resource group:

az group create --name myResourceGroup --location eastus

Create a storage account:

az storage account create --name mystorageaccount --location eastus --resource-group myResourceGroup --sku Standard_LRS

Create a function app:

az functionapp create --resource-group myResourceGroup --consumption-plan-location eastus --runtime python --functions-version 3 --name myfuncapp --storage-account mystorageaccount

Deploy the function app:

func azure functionapp publish myfuncapp

Conclusion

You have successfully created and deployed an Azure Function App using Python and Docker.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published