Terraform-provider-azurerm: "features": required field is not set error for Storage account resource

Created on 24 Feb 2020  ยท  15Comments  ยท  Source: terraform-providers/terraform-provider-azurerm

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

  • Terraform v0.12.21
  • Azurerm provider v2.0.0

Affected Resource(s)

  • azurerm_storage_account

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp
resource "azurerm_storage_account" "storageacc" {
  name                      = "demostorageacc"
  location                  = "eastus"
  resource_group_name       = "resource-demo-group"
  account_tier              = "Standard"
  account_kind              = "StorageV2"
  account_replication_type  = "LRS"
  access_tier               = "hot"

  network_rules {
    default_action = "Allow"
    bypass         = ["AzureServices"]
  }

Description

I was following #5425 to create CORS for blob_properties and had to run terraform init to download new modules/providers/plugins which would support that feature and since then, I am not able to run terraform plan which complains about "features" parameter not set. But that parameter is not part of the resource I am trying to create https://www.terraform.io/docs/providers/azurerm/r/storage_account.html

Debug Output

https://github.com/sai-ns/azure-tf/blob/master/tfdebug

Panic Output

Expected Behavior

Terraform plan should be executed without any issues.

Actual Behavior

Error: "features": required field is not set

Steps to Reproduce

  1. terraform plan

References

  • #2807 #5425

Most helpful comment

You have to define features block with 2.0 provider.
Everything in it is optional, but you need it.
See https://www.terraform.io/docs/providers/azurerm/index.html#argument-reference.

provider "azurerm" {
  version = "=2.0.0"
  features {}
}

All 15 comments

Looks like a dupe of #5866 - you need to pin to version 1 of the azurerm provider.

provider "azurerm" {
  version = "~> 1.44"
}

You have to define features block with 2.0 provider.
Everything in it is optional, but you need it.
See https://www.terraform.io/docs/providers/azurerm/index.html#argument-reference.

provider "azurerm" {
  version = "=2.0.0"
  features {}
}

@DSakura207 yes thats correct, sorry, should have made clear the 1.X pinning is only require if you dont want to upgrade yet.

@DSakura207 thank you. It worked!!
Been waiting for this update for a while to support blob_properties and static_website. But running into issues enabling static_website. Will try to do more digging on it

Error: Error updating Azure Storage Account static_website "storageaccountnamedemo": azure.BearerAuthorizer#WithAuthorization: Failed to refresh the Token for request tohttps://storageaccountnamedemo.blob.core.windows.net?comp=properties&restype=service: StatusCode=400 -- Original Error: adal: Refresh request failed. Status Code = '400'. Response body: {"error":{"code":"invalid_request","message":"No token found for audience https://storage.azure.com/"}}

Edit- Above error disappeared after running apply again

@sai-ns That is ... fun. My error is 403, and I have not tried running it twice. I filed a bug report, but maybe it also had something to do with Microsoft.
Anyway, I'll try again with 2.0 again. Hopefully it works.

I tried creating a Simple test Resource group, but kept getting the error specified in 'Actual Behavior'. I had to use version 1.44, and it worked nicely and created the resource group. 2.0 did not work for me.

I tried creating a Simple test Resource group, but kept getting the error specified in 'Actual Behavior'. I had to use version 1.44, and it worked nicely and created the resource group. 2.0 did not work for me.

Like sai-ns already wrote : add the following code to your terraform code

provider "azurerm" {
  version = "=2.0.0"
  features {}
}

I spend few hours yesterday on a simple Azure Pipeline (that was using a simple tf code to deploy a RG) because of that. Seems like now the provider block is mandantory (it was highly recommended before)

Do we need the
features{}part? What does it do?

nb: https://github.com/terraform-providers/terraform-provider-azurerm/issues/5898

@woeterman94 yes it is required as of version 2.0.0.

You can find more information on this in the docs: https://www.terraform.io/docs/providers/azurerm/index.html#features-2

the error message could be a lot more precise so people that have tens of resources created in one script know what terraform block requires "feature"

I ran into this following https://docs.microsoft.com/en-us/learn/modules/provision-infrastructure-azure-pipelines/4-run-terraform-cloud-shell . It'd be nice to update that tutorial with this information

๐Ÿ‘‹ hi folks

As mentioned in the changelog, version 2.0 of the Azure Provider now requires that a provider block be defined and a features block be defined within it. The features block is new in version 2.0 of the Azure Provider and allows controlling of the behaviour of certain resources (including whether data disks/key vaults should be purged).

Since this controls the behaviour of the Provider this block is now required as we believe it's important that folks are aware which Provider block is being used, since this was ambiguous as it was optional in 1.x (and thus we often saw confusion where users were using one provider block when they thought they were using another with modules).

As mentioned above this should be a case of updating your Terraform Configurations to include a Provider block as shown below:

provider "azurerm" {
  version = "=2.0.0"
  features {}
}

5880 is tracking adding some additional documentation for this however since this should be fixed by updating the Terraform Configuration to include the provider block I'm going to close this issue for the moment, since this is by design in version 2.0 (and upwards) of the Azure Provider.

Thanks!

thanks this is awesome explanation.

Sent from Outlookhttp://aka.ms/weboutlook


From: Tom Harvey notifications@github.com
Sent: Tuesday, March 3, 2020 6:20 PM
To: terraform-providers/terraform-provider-azurerm terraform-provider-azurerm@noreply.github.com
Cc: lindaburns linda_berns@outlook.com; Comment comment@noreply.github.com
Subject: Re: [terraform-providers/terraform-provider-azurerm] "features": required field is not set error for Storage account resource (#5867)

๐Ÿ‘‹ hi folks

As mentioned in the changelog, version 2.0 of the Azure Providerhttps://github.com/terraform-providers/terraform-provider-azurerm/blob/master/CHANGELOG.md#200-february-24-2020 now requires that a provider block be defined and a features block be defined within it. The features block is new in version 2.0 of the Azure Provider and allows controlling of the behaviour of certain resources (including whether data disks/key vaults should be purged).

Since this controls the behaviour of the Provider this block is now required as we believe it's important that folks are aware which Provider block is being used, since this was ambiguous as it was optional in 1.x (and thus we often saw confusion where users were using one provider block when they thought they were using another with modules).

As mentioned above this should be a case of updating your Terraform Configurations to include a Provider block as shown below:

provider "azurerm" {

version = "=2.0.0"

features {}

}

5880https://github.com/terraform-providers/terraform-provider-azurerm/issues/5880 is tracking adding some additional documentation for this however since this should be fixed by updating the Terraform Configuration to include the provider block I'm going to close this issue for the moment, since this is by design in version 2.0 (and upwards) of the Azure Provider.

Thanks!

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/terraform-providers/terraform-provider-azurerm/issues/5867?email_source=notifications&email_token=AKYERG6AYZWFAZ4JPP6O65TRFWGEDA5CNFSM4K2QJUHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENVRX6A#issuecomment-594222072, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKYERG3INPYPPPWHSSICX43RFWGEDANCNFSM4K2QJUHA.

Hi , I have added
provider "azurerm" {
version = "=2.0.0"
features {}
} Still I'm getting features field is not set. any of you getting similar problem ? Please help me

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error ๐Ÿค– ๐Ÿ™‰ , please reach out to my human friends ๐Ÿ‘‰ [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings