A sample Azure Functions 3.0 project with dependency injection, github action deploy routine, ready for local development.
- Ignore the version 2.0 in host.json, it is not related to the runtime version
- Timeout limit and other settings can be specified in host.json
- Create as many folders and functions as you want in the Functions folder
- New functions will appear in Function app after a deploy
Azure Functions will run locally like they run in Azure, if you want to start a timer on demand you can trigger it with a script or use Postman to send requests. Azure blob storage credentials can be added to local.settings.json if you don't like the additional step of starting Azurite manually.
- Install azure-functions-core-tools to get the Func CLI
- Install azurite to get local blob storage
# Prerequisites
npm i -g azure-functions-core-tools@3 --unsafe-perm true
npm i -g azurite
# Build the project
dotnet build
# Run the blob storage emulator
azurite-blob
# Start function host with a single active function
func start --functions HorseTimer
# While function host is running, you can trigger functions with a POST request
http://localhost:7071/admin/functions/HorseTimer
This works just like it does in ASP.NET Core applications
- Add a service to the DI-container in Startup.cs
- View an example service FakeClient.cs
- View an example function HorseTimer.cs
- Create an Azure blob storage account in Azure Portal
- Create an App setting named AzureWebJobsStorage with blob account connection string
- Download publish settings from Azure Function App in Azure Portal
- Create a Github secret named AZURE_FUNCTIONAPP_PUBLISH_PROFILE, paste publish settings
- Insert application name in Github action workflow Azure.yml
- Deploy to Azure by pushing a commit to main branch