Announcing Azure Terrafy and AzAPI Terraform Provider Previews (2024)

Overview

Infrastructure modernization these days typically involves one or more public clouds which enables the most agility, innovation and future proof for your business. A key component that enables businesses to manage their cloud infrastructure in a repeatable, understandable, and safe way is Infrastructure as Code (IaC) Tooling.

On Azure, businesses may choose many flavors of IaC tooling to manage their Azure resources including HashiCorp Terraform, Bicep, ARM templates, Ansibleand many more. We encourage you to choose the IaC tool that best suits your needs. Our mission is to ensure that no matter which tool you choose, you have the best experience and integration with Azure.

To that end, we’re making it easier for you to use HashiCorp Terraform with Azure in two significan ways:

  • By strengthening some of the challenges that our customers have shared with us around Azure Terraform resource support and coverage.
  • By helping export Azure resources into HCL files so that you can manage your infrastructure declaratively using Terraform with Azure.

We are excited to be releasing preview versions of a few new tools that we hope and expect will make your experience with using Terraform on Azure even better than it already is.

Scenarios

Before we dive into the details of the new tooling, let’s take a look at a few scenarios that may resonate with you.

Getting started

Even if you are familiar with Terraform and Azure, sometimes it can be a challenge to determine how to author a Terraform configuration that will result in the exact infrastructure that you are looking for. This typically results in an iterative process where you define a configuration, apply it, then visit the portal to determine if the infrastructure looks like you expected. This is very time consuming, and we are here to help.

Existing Infrastructure

Your current infrastructure was set up by you or someone who came before you. It may have been around “forever,” so who really knows exactly what the settings are now. You’ve adopted IaC for all new deployments and need to make some minor changes to this existing infrastructure or maybe even duplicate it. This sort of task looks daunting, but we’re here to help.

Azure Preview Functionality

The Azure team works hard to add features and functionality that will make your jobs easier. This new functionality is ordinarily released in phases, starting with private and then public preview and, finally, it is stable and made generally available. Many customers, like you, use Terraform to manage their infrastructure and are eager to adopt these new features. Terraform does not usually support these features until the final, generally available stage. This can results in clunky IaC workarounds, but we are here to help.

Escape Hatch

Azure has a vast cornucopia of services and features that are continually expanding and changing. Terraform supports the vast majority of them, but when you need to manage a features or service that is not yet supported, you end up having to fall back on imperfect work arounds, or “escape hatches,” that do not take advantage of all of the goodness you expect from Terraform. This is less than ideal, but we are here to help.

Remove Escape Hatch

With the aforementioned escape hatches are put in place, you can breathe a sigh of relief and get on with the rest of your work. Then the day comes when the “official” support is added to Terraform, and you want to remove those workarounds. The trick nw is to remove the workarounds without having to destroy your infrastructure and redeploy it. This process is anything but straight forward, but we are here to help.

New tools

We want your experience using Terraform with Azure to be delightful, and are super excited to share these open-source tools with you. The preview versions of these tools are available to use today. We invite you to download them and get started.

Azure Terrafy (aztfy)

Scenarios: Getting Started with Terraform, Migrating Existing Infrastructure

With Azure Terrafy, you can quickly and easily turn existing Azure infrastructure into Terraform HCL and will import to Terraform state. After you have completed importing your infrastructure, you can be manage it with your standard IaC processes.

Here’s how:

  1. Simply specify the Azure resource group that has the resources that you wish to start managing with Terraform,
    Announcing Azure Terrafy and AzAPI Terraform Provider Previews (1)
  2. Verify that the AzureRM resource types and resource names are what you expect,
    Announcing Azure Terrafy and AzAPI Terraform Provider Previews (2)
  3. aztfy will do the hard work of creating the HCL, complete with dependencies, and updating the state.
    Announcing Azure Terrafy and AzAPI Terraform Provider Previews (3)
  4. Finally, validate that your configuration matches your infrastructure by running.
    Announcing Azure Terrafy and AzAPI Terraform Provider Previews (4)
  5. The output confirms what you want to know:
    Announcing Azure Terrafy and AzAPI Terraform Provider Previews (5)

Learn more about aztfy from the GitHub repo and download the latest binaries for your OS.

AzAPI Terraform provider

Scenarios: Azure Preview Functionality, Escape Hatch, Remove Escape hatch

The AzAPI provider is a very thin layer on top of the Azure ARM REST APIs. Use this new provider to authenticate to - and manage - Azure resources and functionality using the Azure Resource Manager APIs directly. This provider compliments the Azure Resource Manager provider (AzureRM provider) by enabling the management of Azure resources that are not yet or might never be supported in the AzureRM provider, such as private and public preview services and features.

Unlike some of the workarounds that you might currently be using to manage preview features and functionality such as a null resource to call the Azure CLI, this provider and resources are fully compatible with Terraform. This compatibility ensures that you get all the benefits of Terraform that you rely on.

To allow you to manage all Azure resources and features with this provider without requiring updates, the provider includes the following generic resources:

Resource NameDescription
azapi_resource

Used to fully manage any Azure (control plane) resource (API) with full CRUD. Example use cases:

  • New preview service
  • New feature added to existing service.
  • Existing feature / service not currently covered
azapi_update_resource

Used to manage resources or parts of resources that do not have full CRUD. Example use cases:

  • Update new properties on an existing service.
  • Update pre-created child resource (e.g. DNS SOA record)
Examples
  1. Configure a resource that does not currently exist in the AzureRM provider.Announcing Azure Terrafy and AzAPI Terraform Provider Previews (6)
  2. Configure a preview property for an existing resource from AzureRM.Announcing Azure Terrafy and AzAPI Terraform Provider Previews (7)

Finally, to ensure your experience using the AzAPI provider — from authoring your configuration to migrating to the AzureRM provider—is as easy and streamlined as possible, we’ve created the following tools:

  • The Visual Studio Code extension and language server provides a rich authoring experience, complete with intellisense, code completion, hints, syntax validation, quick info and many other key features.
  • The AzureRM provider provides the best and most integrated Terraform experience for managing Azure resources. Although the AzAPI provider may be used while a service or feature is in preview, we expect customers to move to the AzureRM provider once the service is officially released. To streamline this migration from the AzAPI provider to the AzureRM provider, we have created the AzAPI2AzureRM tool to automate the process of converting AzAPI resources to AzureRM resources.

Learn more about AzAPI provider and associated tools on Microsoft Docs.

Let us hear from you

We look forward to hearing your feedback! Feel free to ask a question, report a problem or suggest a feature by opening an issue in our GitHub repo. If someone else has already mentioned the issue you want to report, let us know it is important to you as well by reacting to the issue with a thumbs-up emoji. To help ensure these tools perform well for you and everyone else, consider tracking the status of your issue and working with us directly in the discussions area.

We would love your continued feedback on Azure Terraform deployments. If you are interested in deeper conversations with the engineering team, sign up for our Azure Terraform community calls.

Announcing Azure Terrafy and AzAPI Terraform Provider Previews (2024)

FAQs

What is AzAPI in Terraform? ›

The AzAPI provider is a thin layer on top of the Azure ARM REST APIs. It enables you to manage any Azure resource type using any API version, enabling you to utilize the latest functionality within Azure.

What is AzureRM in Terraform? ›

There are several Terraform providers that enable the management of Azure infrastructure: AzureRM: Manage stable Azure resources and functionality such as virtual machines, storage accounts, and networking interfaces. AzAPI: Manage Azure resources and functionality using the Azure Resource Manager APIs directly.

How to use Azure Terraform? ›

Get Started - Azure
  1. 3min. What is Infrastructure as Code with Terraform? ...
  2. 9min. Install Terraform. ...
  3. 10min. Build infrastructure. ...
  4. 4min. Change infrastructure. ...
  5. 3min. Destroy infrastructure. ...
  6. 4min. Define input variables. ...
  7. 2min. Query data with output values. ...
  8. 8min. Store remote state.

How do you handle Terraform errors? ›

How to troubleshoot Terraform errors?
  1. Understand the Error Message. Read the error message carefully to understand what caused the error. ...
  2. Check Terraform Documentation. ...
  3. Review the Configuration File. ...
  4. Validate the Configuration. ...
  5. Plan the Changes. ...
  6. Check Provider Versions. ...
  7. Check Provider Credentials. ...
  8. Debug Log Output.

Why use Terragrunt over Terraform? ›

Terraform requires manual structuring of modules for reusability, which can lead to redundancy if not managed carefully. Terragrunt offers built-in support for DRY configurations using its include and dependency blocks, significantly reducing boilerplate and improving maintainability.

What is a provider in Terraform? ›

What Are the Providers in Terraform? A provider in Terraform is a plugin that enables interaction with an API. This includes Cloud providers and Software-as-a-service providers. The providers are specified in the Terraform configuration code. They tell Terraform which services it needs to interact with.

What are Terraform commands? ›

Basic Terraform commands
  • Prepare Cloud Shell.
  • Prepare the directory.
  • Apply the changes.
  • Reformat.
  • Validate.
  • Delete changes.
  • Specify the project ID.
  • What's next.

How to create VNET using Terraform? ›

In this quickstart, you learn about a Terraform script that creates an Azure resource group and a virtual network with two subnets. The script generates the names of the resource group and the virtual network by using a random pet name with a prefix. The script also shows the names of the created resources in output.

How do I write a Terraform script for Azure? ›

  1. Install the Azure CLI tool. You will use the Azure CLI tool to authenticate with Azure. ...
  2. Create a Service Principal. Next, create a Service Principal. ...
  3. Set your environment variables. ...
  4. Terraform Block. ...
  5. Providers. ...
  6. Resource.

What is Terraform used for? ›

Terraform is an IAC tool, used primarily by DevOps teams to automate various infrastructure tasks. The provisioning of cloud resources, for instance, is one of the main use cases of Terraform. It's a cloud-agnostic, open-source provisioning tool written in the Go language and created by HashiCorp.

How do I deploy a Terraform file to Azure? ›

  1. Configure your environment. Azure subscription: If you don't have an Azure subscription, create a free account before you begin. ...
  2. Create and apply the Terraform plan. Browse to the Azure portal. ...
  3. Fork the test project. ...
  4. Deploy from GitHub to your deployment slots. ...
  5. Test the app deployments. ...
  6. Swap the two deployment slots.
Aug 13, 2024

How to check if Terraform is working? ›

The terraform validate command validates the configuration files in a directory, referring only to the configuration and not accessing any remote services such as remote state, provider APIs, etc.

What are the Terraform commands? ›

Basic Terraform commands
  • Prepare Cloud Shell.
  • Prepare the directory.
  • Apply the changes.
  • Reformat.
  • Validate.
  • Delete changes.
  • Specify the project ID.
  • What's next.

What is the use of concat in Terraform? ›

Both methods allow you to perform simple string concatenation in Terraform, with ${} syntax being more suitable for interpolating variables directly into strings, while the join() function is useful for concatenating elements of a list or multiple strings with a specified separator.

What are plugins you used in Terraform? ›

Terraform Plugins

Each plugin exposes an implementation for a specific service, such as AWS, or provisioner, such as bash. All Providers and Provisioners used in Terraform configurations are plugins. They are executed as a separate process and communicate with the main Terraform binary over an RPC interface.

What is the function of chomp in Terraform? ›

chomp Function

chomp removes newline characters at the end of a string. This can be useful if, for example, the string was read from a file that has a newline character at the end.

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Amb. Frankie Simonis

Last Updated:

Views: 5777

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Amb. Frankie Simonis

Birthday: 1998-02-19

Address: 64841 Delmar Isle, North Wiley, OR 74073

Phone: +17844167847676

Job: Forward IT Agent

Hobby: LARPing, Kitesurfing, Sewing, Digital arts, Sand art, Gardening, Dance

Introduction: My name is Amb. Frankie Simonis, I am a hilarious, enchanting, energetic, cooperative, innocent, cute, joyous person who loves writing and wants to share my knowledge and understanding with you.