Run Azure CLI Commands With Terraform

In this blog post, I will show you how to run Azure CLI commands with Terraform if the Azure provider doesn’t support an action.


When working with Microsoft Azure, you might come across a situation where the provider cannot act or even exist for service.

This can happen since the community supports the Azure provider, and there is no sync between Microsoft Azure development and the provider modules’ development cycle.

For the above reasons, Terraform has the concept and provisioners where you can run Terraform and then run commands remotely or locally. In our case, I will use the Azure CLI command in my Terraform configuration.

The Azure CLI command that I’m using is just a sample, but the concept can be used with Azure CLI commands or commands.

Run Azure CLI Commands With Terraform

Before you run the code, make sure you log in to Azure using the following commands:

The code below will create a resource group and run an Azure CLI command.

For more Terraform and Azure articles, please visit our Terraform category page.