<p>You can use <strong>Terraform for azure</strong> to handle the dynamic creation of azure resources in the release pipeline in Azure DevOps. Terraform maintains a state file for all the created resources after a run. </p>

<p>If the script is run multiple times, it ignores already created resources unless there are any properties updated and created new resources.</p>

<p>FYI, follow below link for a quick example
<a href="https://docs.microsoft.com/en-us/azure/terraform/terraform-create-complete-vm" rel="nofollow noreferrer">Terraform example</a></p>

CC BY-SA 4.0
2020-03-03T20:22:32.887Z
Nice. I wasn't aware of the existence of it. I have a couple of questions though.
1) Would you add this steps in the same deploy pipeline or in a separate one?
2) This seems to work for VMs and that kind some "standard" resources? What about resources that are very specific to Azure? Does Terraform support all of them?
empz
CC BY-SA 4.0
2020-03-04T01:59:38.007Z
@emzero, 1. you can actually put it as the first step in your release pipeline. You can put your terraform script file in your source control and add a terraform step in pipeline. 2. There is no such limitation on creating resources using terraform, its an alternative to ARM templates, you can create all kinds of resources. Below link has examples for all kinds of resources https://www.terraform.io/docs/providers/azurerm/index.html
Raju Dasupally
CC BY-SA 4.0
2020-03-03T16:08:39.470Z
2020-03-03T16:08:39.470Z
Raju Dasupally
<p>We're moving from a .NET monolithic application to a microservices architecture hosted on Azure.</p>

<p>Until now, we only had one build definition on TFS and a release definition for each environment (development, staging and production).
All the Azure resources needed to deploy to each environment were created manually. We want to automate this part.</p>

<p>How's the recommended approach to handle new resources setup? Do you just put steps in the release pipeline that will create the needed resources when they don't exist? Or do you have a separate pipeline that's solely responsible for creating all the resources for a new environment?</p>

<azure-devops><microservices><release-management><tfs><environments>
How to handle resource creation?
empz
# How to handle resource creation?

(Asked by: username_0 on 2020-02-12)

We're moving from a .NET monolithic application to a microservices architecture hosted on Azure.

Until now, we only had one build definition on TFS and a release definition for each environment (development, staging and production).
All the Azure resources needed to deploy to each environment were created manually. We want to automate this part.

How's the recommended approach to handle new resources setup? Do you just put steps in the release pipeline that will create the needed resources when they don't exist? Or do you have a separate pipeline that's solely responsible for creating all the resources for a new environment?

**Tags:** azure-devops, microservices, release-management, tfs, environments


---

## 1 answers

### Answer by username_1 on 2020-03-03. Score: 1 | Accepted answer

You can use **Terraform for azure** to handle the dynamic creation of azure resources in the release pipeline in Azure DevOps. Terraform maintains a state file for all the created resources after a run.

If the script is run multiple times, it ignores already created resources unless there are any properties updated and created new resources.

FYI, follow below link for a quick example
[Terraform example](https://docs.microsoft.com/en-us/azure/terraform/terraform-create-complete-vm)

> **Comments:**
> **username_0**: Nice. I wasn't aware of the existence of it. I have a couple of questions though. 1) Would you add this steps in the same deploy pipeline or in a separate one? 2) This seems to work for VMs and that kind some "standard" resources? What about resources that are very specific to Azure? Does Terraform support all of them?  
> **username_1**: @emzero, 1. you can actually put it as the first step in your release pipeline. You can put your terraform script file in your source control and add a terraform step in pipeline. 2. There is no such limitation on creating resources using terraform, its an alternative to ARM templates, you can create all kinds of resources. Below link has examples for all kinds of resources https://www.terraform.io/docs/providers/azurerm/index.html  

---

