Azure Resource Management (ARM) provisioning
Provision Azure resources using ARM templates in Harness.
Harness supports Azure Resource Manager (ARM) templates as an infrastructure provisioner. You can use ARM templates to provision deployment target infrastructure in Azure or to provision any Azure resources.
This topic provides steps on using Harness to provision target environment resources using ARM templates.
What you will learn from this topic
How to understand the supported deployment types, scopes, and deployment modes for Azure ARM provisioning.
How to choose between ad hoc provisioning and dynamic provisioning for Azure ARM.
How to create the Azure ARM Resources step and configure ARM templates and parameters.
How to roll back ARM provisioning using the Azure ARM Rollback step.
How to assemble complete pipeline examples for ad hoc and dynamic provisioning.
Supported deployment types, scopes, and modes
Harness ARM provisioning is supported in the following deployment types:
Basic
Canary
Blue-Green
Harness ARM provisioning is used to deploy Azure Web Apps. You can use ARM templates to provision any Azure resources, but deployment target provisioning is limited to Azure Web App deployments.
Harness supports the following Azure ARM deployment scopes:
Tenant
Management Group
Subscription
Resource Group
Harness supports the following deployment modes (configurable in YAML):
Incremental mode (default): Supported for all scope types (Tenant, Management Group, Subscription, Resource Group). In Incremental mode, Resource Manager leaves unchanged resources that exist in the resource group but are not specified in the template.
Complete mode: Supported for Resource Group scope only. In Complete mode, Resource Manager deletes resources that exist in the resource group but are not specified in the template.
For more information, go to Azure Resource Manager deployment modes in the Azure documentation.
Before you begin
Harness project access: View, Create/Edit, and Execute permissions on Pipelines, Environments, and Infrastructure Definitions. Go to RBAC in Harness to configure roles.
Azure connector: A Harness Azure connector with permissions to provision resources in your target subscription or resource group. Go to Add Microsoft Azure connector to configure the connector and review required Azure roles for ARM provisioning.
Harness Delegate: A delegate installed in an environment that can connect to Azure. Go to Delegate installation overview to install a delegate.
ARM template file: A JSON ARM template that defines the resources to provision. ARM templates must be in JSON format; Bicep is not supported.
Provisioning modes
Harness supports two Azure ARM provisioning modes:
Ad hoc provisioning: Provision infrastructure as a standalone task without deploying an application in the same flow.
Dynamic provisioning: Provision the target infrastructure and deploy your application to it in the same stage.
The pipeline steps are configured the same way for both modes. Choose the mode that matches your goal: use ad hoc provisioning to manage infrastructure on its own, and dynamic provisioning to provision and deploy in one stage.
Go to Provisioning overview to understand Harness provisioning concepts and use cases.
Ad hoc provisioning
Ad hoc provisioning lets you provision infrastructure as a standalone workflow without deploying an application in the same flow. This mode is useful to create test environments, set up shared resources, or make infrastructure changes independently of application deployments.
For ad hoc provisioning, add the Azure ARM Resources step to the Execution section of a CD Deploy stage. The step provisions your resources when the stage runs.
Example use cases:
Provision a shared Azure resource group or storage account that other pipelines consume.
Stand up a temporary test environment for validation, then destroy it in a later step.
Run a one-time infrastructure change defined in an ARM template.
To configure ad hoc provisioning, go to Create Azure ARM Resources step and Pipeline examples.
Dynamic provisioning
For dynamic provisioning, add the Azure ARM Resources step to the Environment section of a CD Deploy stage and map the ARM template outputs to the Infrastructure Definition. Harness then deploys your application to the provisioned infrastructure in the same stage.
Example use cases:
Provision an Azure Web App resource group and deploy a containerized application to it in a single pipeline.
Create ephemeral Azure resources per pull request, deploy to them, and tear them down afterward.
Each Harness deployment type requires different ARM template outputs to be mapped to its infrastructure settings. Go to the topic for your deployment type to understand which ARM template outputs are required:
Azure Web Apps: Web App deployments.
Tanzu Application Services: Tanzu (Pivotal Cloud Foundry) deployments.
VM deployments using SSH: Traditional virtual machine deployments over SSH.
Windows VM deployments using WinRM: Windows virtual machine deployments over WinRM.
To configure dynamic provisioning, go to Create Azure ARM Resources step and Pipeline examples.
Create an Azure ARM Resources step
The Create Azure ARM Resources step provisions infrastructure resources using the ARM template file you provide.
Perform the following steps to add and configure the Create Azure ARM Resources step:
In your Harness CD Deploy stage, add the Create Azure ARM Resources step.
If you are using the step for dynamic infrastructure provisioning, add the step in the stage Environment tab.
If you are using the step for ad hoc provisioning, add the step in the stage Execution tab.
In Name, enter a name for the step.
Configure the step settings described in the sections below.
Select Apply Changes.
Provisioner Identifier
In Provisioner Identifier, enter a unique value to reference the provisioning performed by this step in subsequent steps. The Provisioner Identifier is used by the Azure ARM Rollback step to identify which ARM deployment to roll back.
The Provisioner Identifier is project-wide, so ensure it is unique across all pipelines in the project. Coordinate with your team to prevent one pipeline from accidentally impacting the provisioning state of another pipeline.
Azure Connector
In Azure Connector, select or create a Harness Azure connector that Harness will use to connect to Azure and provision the template. Go to Add Microsoft Azure connector to configure the connector.
ARM Template File
In ARM Template File, provide the ARM template file to use for provisioning. The template must be in JSON format. You can store the template in the Harness File Store, a Git repository, or inline.
ARM Parameter File
In ARM Parameter File, link the template parameters. Harness accepts ARM template parameters in a specific JSON format.
Harness provisioning requires you to remove the $schema and contentVersion keys from the parameters JSON due to limitations in the Azure Java SDK and REST APIs. Only the parameters object with key-value pairs is allowed.
When you use parameters in Harness, remove the $schema and contentVersion keys. Provide only the parameters object:
You can store the parameters file in the Harness File Store, a Git repository, or inline.
Scope
In Scope, select the Azure scope for the deployment: Tenant, Management Group, Subscription, or Resource Group.
The scope you select determines which Azure resources can be provisioned and what additional configuration is required.
Subscription
When you select Subscription scope, provide:
Subscription ID: The Azure subscription where the resources will be provisioned.
Location: The Azure region for the deployment (for example,
South India,East US,West Europe).
Resource Group
When you select Resource Group scope, provide:
Subscription ID: The Azure subscription that contains the resource group.
Resource Group: The resource group for the provisioned resources.
ARM template outputs for dynamic provisioning
When using dynamic provisioning, your ARM template must include an outputs section that exports the values required by the Infrastructure Definition. Harness references these outputs using the expression <+provisioner.PROVISIONER_ID.OUTPUT_NAME>.
For example, for Azure Web App deployments, your ARM template should export the web app name and deployment slot:
In the Infrastructure Definition, reference these outputs:
Web App:
<+provisioner.dynamicarm.webAppName>Deployment Slot:
<+provisioner.dynamicarm.slotName>
Replace dynamicarm with your Provisioner Identifier value from the Create Azure ARM Resources step.
Azure ARM Resources step - YAML example
The following YAML examples demonstrate different scope configurations. Replace the placeholder values with your own.
Create an Azure ARM Rollback step
The Azure ARM Rollback step rolls back the provisioning performed by a Create Azure ARM Resources step. Rollback is supported for Resource Group scope only.
To roll back Azure ARM provisioning performed by a Create Azure ARM Resources step, add an Azure ARM Rollback step and reference the Provisioner Identifier from the Create Azure ARM Resources step.
Perform the following steps to add and configure the Azure ARM Rollback step:
In your Harness CD Deploy stage, add the Azure ARM Rollback step to the Rollback section.
In Name, enter a name for the step.
In Provisioner Identifier, enter the same Provisioner Identifier value you used in the Create Azure ARM Resources step.
Select Apply Changes.
When Harness runs a stage that performs provisioning using an ARM template, Harness generates a template for the existing resource group and saves it before starting the ARM deployment. During rollback, this template is used to restore the resource group to its state before the deployment started.
Advanced step settings
In the Advanced tab of the Create Azure ARM Resources and Azure ARM Rollback steps, you can configure the following options:
Pipeline examples
The following examples demonstrate ad hoc and dynamic provisioning with the Create Azure ARM Resources step. Replace the connector references, subscription, resource group, and file paths with your own values.
Ad hoc provisioning
The following example demonstrates ad hoc provisioning with the Create Azure ARM Resources step in the Execution section of a CD Deploy stage. This example uses a minimal ARM template at Subscription scope that outputs parameter values.
Dynamic provisioning
The following example demonstrates dynamic provisioning with the Create Azure ARM Resources step in the Environment section of a CD Deploy stage. The ARM template outputs are mapped to the Infrastructure Definition, allowing Harness to deploy to the provisioned resources.
Map ARM outputs to Infrastructure Definition
For dynamic provisioning to work, you must map ARM template outputs to the Infrastructure Definition fields. The example below shows how to reference template outputs using <+provisioner.PROVISIONER_ID.OUTPUT_NAME>.
If you use <+input> for infrastructure fields in dynamic provisioning, the deployment will fail with ResourceNotFound errors because Harness cannot resolve the resource names.
Next steps
Go to Azure Web Apps deployment tutorial to provision Azure Web App infrastructure with ARM and deploy applications.
Go to Provisioning overview to understand Harness provisioning concepts and use cases across all supported provisioners.
Last updated
Was this helpful?