The AzAPI Terraform Provider simplifies the deployment and management of Microsoft Azure resources by providing a streamlined solution built on top of Azure ARM REST APIs. This provider enables the management of any Azure resource, regardless of the Azure ARM API version being used. Its primary advantage is the ability to deploy and manage new Azure resources and properties that may not be supported by the azurerm Terraform Provider, making it a versatile tool for Azure resource management.
The AzAPI Terraform Provider streamlines the management of Microsoft Azure Preview Resources and Properties not yet supported by the azurerm Terraform Provider. This provider focuses on offering management capabilities for a limited set of Azure resources and properties, making it simple yet powerful.
The provider consists of two Terraform resources:
1. azapi_resource – For managing Azure Resources not supported by the azurerm Terraform Provider.
2. azapi_update_resource – For managing Preview Properties of Azure Resources not supported by the azurerm Terraform Provider.
3. azapi_resource_action - This resource can perform any Azure resource manager resource action. It's recommended to use it to perform actions which change a resource's state, please use azapi_resource_action data source, if user wants to perform readonly action, such as start/stop a virtual machine
In general, when managing Azure Resources through Terraform Infrastructure as Code, it's recommended to use the azurerm Terraform Provider. However, when encountering unsupported resources or properties, the AzAPI Terraform Provider steps in to provide the necessary management capabilities.
Built as a thin layer on top of Azure ARM REST APIs, the AzAPI Terraform Provider is able to manage any Azure Resource by specifying the Resource Type symbolic name and API Version. This versatility makes the AzAPI Terraform Provider a valuable tool for managing Azure Preview Resources and Properties from Terraform.
The azapi_resource definition is a solution for managing Azure resources that are not supported by the azurerm Terraform Provider. It requires the "type" attribute to be set to the desired Azure ARM resource type and API version within the Azure REST API.
As an example, the following code manages the Azure Custom IP Prefixes resource (Microsoft.Network/customIpPrefixes) using the 2021-03-01 API version:
In this example, several attributes are configured in addition to the type:
The azapi_update_resource is a tool for managing preview properties of Azure resources that have not yet been supported by the azurerm Terraform provider. This resource utilizes the Azure ARM (Azure Resource Manager) REST APIs to manage these properties, by setting the type attribute to the desired Azure Resource Type name and API version.
As an example, consider the scenario where you need to set the anonymousPullEnabled Preview Feature for the Azure Container Registry resource (Microsoft.ContainerRegistry/registries) using the 2020-11-01-preview API Version. The code would look like this:
In this example, the properties attribute is used to define the preview feature that you want to set. The name attribute sets the name of the Azure resource, and the parent_id attribute sets the ID of the parent resource group for the registry.
The azapi_update_resource resource is a convenient way to manage preview features of Azure resources when those features are not yet supported by the azurerm Terraform provider.
Remember to select the right resource from the AzAPI provider to complete actions correctly.
Mohammad Al Rousan is a Microsoft MVP (Azure), Microsoft Certified Solution Expert (MCSE) in Cloud Platform & Azure DevOps & Infrastructure, An active community blogger and speaker.
Al Rousan has over 8 years of professional experience in IT Infrastructure and very passionate about Microsoft technologies and products.
Top 10 Microsoft Azure Blogs