In order for the Terraform Azure provider to provision and manipulate resources in Azure, the provider must authenticate in Azure using an Azure account and that account must have the correct authorizations.
In the previous recipe, we studied how to automatically authenticate the Terraform context in Azure Cloud Shell with our personal account and permissions. However, in corporate projects, as well as in production, it is very bad practice to use your personal account as this could expire, be deleted, or, even worse, be misused.
This is why one of the options we have when running Terraform in Azure is to use an App Registration account (also known as Service Principal) that is not linked to a physical person.
In this recipe, we will first study the creation of this Service Principal and then we will see how to use it securely in order to run a Terraform configuration.
Getting ready
To apply the first part of this recipe, you must have user account...