hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.64k forks source link

Cannot create `azurerm_managed_lustre_file_system` resource due to `The subscription is not registered to use namespace 'Microsoft.StorageCache'` error #23567

Open lonegunmanb opened 1 year ago

lonegunmanb commented 1 year ago

Is there an existing issue for this?

Community Note

Terraform Version

v1.6.0

AzureRM Provider Version

v3.76.0

Affected Resource(s)/Data Source(s)

azurerm_managed_lustre_file_system

Terraform Configuration Files

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "zjhe-lustre"
  location = "West Europe"
}

resource "azurerm_virtual_network" "example" {
  name                = "example-vnet"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
}

resource "azurerm_subnet" "example" {
  name                 = "example-subnet"
  resource_group_name  = azurerm_resource_group.example.name
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["10.0.2.0/24"]
}

resource "azurerm_managed_lustre_file_system" "example" {
  name                   = "example-amlfs"
  resource_group_name    = azurerm_resource_group.example.name
  location               = azurerm_resource_group.example.location
  sku_name               = "AMLFS-Durable-Premium-250"
  subnet_id              = azurerm_subnet.example.id
  storage_capacity_in_tb = 8
  zones                  = ["2"]

  maintenance_window {
    day_of_week     = "Friday"
    time_of_day_in_utc = "22:00"
  }
}

Debug Output/Panic Output

╷
│ Error: creating Aml Filesystem (Subscription: "xxxxxx"
│ Resource Group Name: "zjhe-lustre"
│ Aml Filesystem Name: "example-amlfs"): performing CreateOrUpdate: Put "https://management.azure.com/subscriptions/xxxxxx/resourceGroups/zjhe-lustre/providers/Microsoft.StorageCache/amlFilesystems/example-amlfs?api-version=2023-05-01": The Resource Provider was not registered
│
│ Resource Providers (APIs) in Azure need to be registered before they can be used - however the Resource
│ Provider was not registered, and calling the API returned the following error:
│
│ The subscription is not registered to use namespace 'Microsoft.StorageCache'. See https://aka.ms/rps-not-found for how to register subscriptions. >
│
│ The Azure Provider by default will automatically register certain Resource Providers at launch-time,
│ whilst it's possible to opt-out of this (which you may have done)
│
│ Please ensure that this Resource Provider is properly registered, you can do this using the Azure CLI
│ for example to register the Resource Provider "Some.ResourceProvider" is registered run:
│
│ > az provider register --namespace "Some.ResourceProvider"
│
│ Resource Providers can take a while to register, you can check the status by running:
│
│ > az provider show --namespace "Some.ResourceProvider" --query "registrationState"
│
│ Once this outputs "Registered" the Resource Provider is available for use and you can re-run Terraform.
│
│
│   with azurerm_managed_lustre_file_system.example,
│   on main.tf line 24, in resource "azurerm_managed_lustre_file_system" "example":
│   24: resource "azurerm_managed_lustre_file_system" "example" {
│
│ creating Aml Filesystem (Subscription: "xxxxxx"
│ Resource Group Name: "zjhe-lustre"
│ Aml Filesystem Name: "example-amlfs"): performing CreateOrUpdate: Put
│ "https://management.azure.com/subscriptions/xxxxxx/resourceGroups/zjhe-lustre/providers/Microsoft.StorageCache/amlFilesystems/example-amlfs?api-version=2023-05-01":
│ The Resource Provider was not registered
│
│ Resource Providers (APIs) in Azure need to be registered before they can be used - however the Resource
│ Provider was not registered, and calling the API returned the following error:
│
│ The subscription is not registered to use namespace 'Microsoft.StorageCache'. See https://aka.ms/rps-not-found for how to register   
│ subscriptions. >
│
│ The Azure Provider by default will automatically register certain Resource Providers at launch-time,
Terraform v1.6.0

Expected Behaviour

Resource created successfully.

Actual Behaviour

No response

Steps to Reproduce

terraform apply -auto-approve

Important Factoids

No response

References

This issue caused testing error for https://github.com/Azure/terraform/pull/258. It looks like we need to add Microsoft.StorageCache into func Required() map[string]struct{} function in the provider.

EppO commented 1 year ago

I get this also when deploying a Managed Grafana resource in a new subscription, it looks like the AzureRM provider doesn't register automatically the Resource Provider (even without skip_provider_registration in the provider block).