Let’s see how to create a remote state in a storage account for terraform So that Azure DevOps Pipelines can utilize them.
Create a Storage Account
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-38.png)
Leave things default
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-39.png)
Leave things default
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-40.png)
Enable Versioning for blobs.
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-41.png)
–
Create Storage Account
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-42.png)
Create Container named tfstatefiles
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-43-1024x542.png)
Created Service Connections
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-44-1024x204.png)
Update terraform with backend.tf
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-56-1024x358.png)
Terraform – Visual Studio Marketplace
Install Terraform DevOps Extensions
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-45.png)
Make sure it runs on Azure Pipelines agent – like ubuntu
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-48-1024x306.png)
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-49-1024x385.png)
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-50-1024x649.png)
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-51-1024x504.png)
Apply
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-53-1024x520.png)
if you are using .tfvars
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-52-1024x502.png)
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-54-1024x273.png)
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-57-1024x250.png)
You can see the state file gets locked
![](https://www.azure365pro.com/wp-content/uploads/2023/04/image-58.png)