Unable to create azure resource group by using Terraform command in PowerShell

Jayesh Mhatre 10 Reputation points
2024-08-29T05:14:50.79+00:00

Unable to create Azure resource group by using Terraform command in PowerShell

error- Error: subscription_id is a required provider property when performing a plan/apply operation

As checked my subsciption is Active

(Taken code from official website link- https://registry.terraform.io/providers/hashicorp/azurerm/latest)

terraform {

required_providers {

azurerm = {

  source = "hashicorp/azurerm"

  version = "4.0.1"

}

}

}

provider "azurerm" {

features {}

}

resource "azurerm_resource_group" "RGJayesh" {

name = "JayeshRG1"

location = "West Europe"

}

Please help me to fix this issue

Azure | Azure Training
{count} vote

4 answers

Sort by: Most helpful
  1. Prrudram-MSFT 28,391 Reputation points Microsoft Employee Moderator
    2024-08-29T09:48:46.04+00:00

    Hi @Jayesh Mhatre

    Happy to help!

    The subscription_id property is missing in your Terraform configuration file.

    To fix this issue, you need to add the subscription_id property to your Terraform configuration file. You can get the subscription ID from the Azure portal or by using the Azure CLI. Here is an example of how to add the subscription_id property to your Terraform configuration file:

    provider "azurerm" {
      subscription_id = "your-subscription-id"
      # other provider properties
    }
    
    # other resources
    
    

    If this is the first time you are working on this topic, you can refer to the below blog which i found to be clear and precise https://www.geeksforgeeks.org/how-to-create-azure-resource-group-using-terraform/

    also, please consider checking the hashicorp/azurerm version as suggested by Sasser Barry

    If I have answered your query, please click "Accept as answer" as a token of appreciation

    3 people found this answer helpful.

  2. Marco Vervoort 11 Reputation points
    2024-12-12T13:45:52.3966667+00:00

    This can also be solved by setting the environment variable "ARM_SUBSCRIPTION_ID" like:

    $SubscriptionId = az account show --query id -o tsv
    $env:ARM_SUBSCRIPTION_ID = $SubscriptionId
    

    Then you can omit the subscription_id = "0000000-0000-00000-000000" in the azurerm provider registration.

    2 people found this answer helpful.
    0 comments No comments

  3. Zafer KAYA 90 Reputation points MVP
    2024-11-18T11:57:07.3433333+00:00

    Hello, if the Azure Subscription status is active or disabled, you may be getting an error due to this, please check your subscription status.

    0 comments No comments

  4. Joni Zhao 0 Reputation points
    2025-08-27T09:11:02.18+00:00

    From my side, I used a outlook acount(personal account) to login to the Azure cloud,
    so same error happend.
    After I changed to the Entra ID account or SPN with a contributor role to do this again, it just fixed.
    Hope it helps.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.