WorkingDirectory icon
Clone icon
Commands icon
AzCLI icon
Request icon
Download icon
azure icon

Deploy an Azure Function from Git and Chain a Logic App

Kestra flow that clones a repo, zips the code, runs az functionapp create and config-zip via AzCLI with a service principal, then triggers a Logic App.

Categories
Cloud

Ship an Azure Function from a Git repository to a live consumption-plan app in one governed run. This Kestra blueprint clones the function source, packages it as a zip artifact inside a shared working directory, creates the Function App with the Azure CLI, and pushes the code with zip deployment. It then goes one step further than a plain CI job: it invokes a downstream Azure Logic App over its HTTP trigger and downloads the artifact the Logic App returns, showing how Kestra can chain Azure serverless services into a single pipeline. All Azure authentication is handled once through pluginDefaults with a service principal, so no task carries its own credentials.

How it works

  1. The wdir task (io.kestra.plugin.core.flow.WorkingDirectory) gives the next four tasks a shared filesystem.
  2. The clone task (io.kestra.plugin.git.Clone) pulls the function project from Git into azure-function-demo. Point url at your real repository.
  3. The zip task (io.kestra.plugin.scripts.shell.Commands) installs zip, packages the project as release.zip, and moves it to {{ workingDir }} for the deploy step.
  4. The cli task (io.kestra.plugin.azure.cli.AzCLI) runs az functionapp create with a Python 3.9 runtime on a Linux consumption plan, using the resourceGroup, region, and storageAccount variables plus the name input.
  5. The deploy_func task (io.kestra.plugin.azure.cli.AzCLI) runs az functionapp deployment source config-zip to push release.zip to the new app.
  6. The trigger_logic_api task (io.kestra.plugin.core.http.Request) POSTs to an Azure Logic App HTTP trigger, with the workflow key and SAS signature kept in secrets.
  7. The get_data task (io.kestra.plugin.core.http.Download) extracts a URL from the Logic App's JSON response with jq('.message') and downloads the artifact into Kestra's internal storage.
  8. A pluginDefaults block injects the service principal (AZURE_SP_APP_ID, AZURE_SP_PASSWORD, AZURE_TENANT_ID) into every io.kestra.plugin.azure task.

What you get

  • Git-to-Azure deployment with the exact commit and CLI output captured per execution.
  • One place for Azure auth via pluginDefaults, no repeated credential blocks.
  • A working pattern for chaining Functions and Logic Apps in a single orchestrated run.
  • Parameterized app naming through the name input for repeatable POC or per-branch deployments.

Who it's for

  • Platform engineers standing up Azure Functions without a dedicated CI/CD stack.
  • Azure teams composing Functions, Logic Apps, and storage into end-to-end automations.
  • Consultants and SEs who need a reproducible, parameterized Azure deployment demo.

Why orchestrate this with Kestra

Azure DevOps pipelines or GitHub Actions can zip-deploy a function, but they stop at the deploy. Kestra treats the deployment as one step in a larger orchestration: the same execution that ships the code can call the Logic App that depends on it, capture its output as a downloadable artifact, and expose every CLI log line in one UI. Variables and inputs make the flow reusable across environments, pluginDefaults centralizes the service principal, and the whole pipeline is version-controlled YAML you can promote between instances.

Prerequisites

  • An Azure subscription with an existing resource group and storage account (set the resourceGroup, region, and storageAccount variables).
  • A service principal with rights to create and deploy Function Apps.
  • A Git repository containing a deployable Azure Function project.
  • Optionally an Azure Logic App with an HTTP request trigger for the chaining step, or remove the last two tasks.

Secrets

  • AZURE_SP_APP_ID, AZURE_SP_PASSWORD, AZURE_TENANT_ID: service principal used by all AzCLI tasks.
  • LOGIC_APP_KEY: the workflow id segment of the Logic App trigger URL.
  • LOGIC_APP_SIG: the SAS signature (sig parameter) of the Logic App trigger URL.

Quick start

  1. Add the secrets to your Kestra namespace.
  2. Update the variables and the clone task url to your repo, and adjust the Logic App region and host in trigger_logic_api.
  3. Deploy the flow and execute it with a globally unique name input.
  4. Watch the cli and deploy_func logs, then verify the Function App in the Azure portal.
  5. Inspect the downloaded Logic App artifact in the execution outputs.

How to extend

  • Trigger on push with io.kestra.plugin.core.trigger.Webhook wired to your Git provider.
  • Add a smoke test task that calls the deployed function URL before declaring success.
  • Split create and deploy so existing apps skip az functionapp create with a runIf condition.
  • Promote through environments by overriding vars per namespace or tenant.
  • Add an approval gate with io.kestra.plugin.core.flow.Pause before deploying to production.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.