Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot register providers: Microsoft.Compute. Errors were: waiting for Subscription Provider #23195

Closed
1 task done
sreekanth3107 opened this issue Sep 6, 2023 · 5 comments

Comments

@sreekanth3107
Copy link

sreekanth3107 commented Sep 6, 2023

Is there an existing issue for this?

  • I have searched the existing issues

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 and review the contribution guide to help.

Terraform Version

1.5.6

AzureRM Provider Version

v3.65.0

Affected Resource(s)/Data Source(s)

azurerm

Terraform Configuration Files

provider "azurerm" {
features{}
}

Debug Output/Panic Output

Error: Error ensuring Resource Providers are registered.
Terraform automatically attempts to register the Resource Providers it supports to ensure it's able to provision resources.
If you don't have permission to register Resource Providers you may wish to use the "skip_provider_registration" flag in the Provider block to disable this functionality.
> API version 2019-XX-XX was not found for Microsoft.Foo
Could indicate either that the Resource Provider "Microsoft.Foo" requires registration,
but this could also indicate that this Azure Region doesn't support this API version.

Original Error: Cannot register providers: Microsoft.Compute. Errors were: waiting for Subscription Provider (Subscription: "XXX"
Provider Name: "Microsoft.Compute") to be registered: context deadline exceeded 	
with provider["registry.terraform.io/hashicorp/azurerm"],

Expected Behaviour

successful apply

Actual Behaviour

provider crashed

Steps to Reproduce

No response

Important Factoids

No response

References

I find a issue in Microsoft Q/A but this doesn't help because we didn't change any permissions expect the azurerm provider version. This is effected only newly created subs
https://learn.microsoft.com/en-us/answers/questions/1354723/could-not-register-the-resource-provider-microsoft
No response

@Mike-Nahmias
Copy link

Mike-Nahmias commented Sep 6, 2023

I've been having this problem a lot lately. The azurerm provider seems to wait for all of the resource providers it registers to enter the "Registered" state, but I keep running into problems where some of these are stuck "Registering" for 12+ hours. This is against Microsoft's recommendation in this article:

Your application code shouldn't block the creation of resources for a resource provider that is in the registering state. When you register the resource provider, the operation is done individually for each supported region. To create resources in a region, the registration only needs to be completed in that region. By not blocking a resource provider in the registering state, your application can continue much sooner than waiting for all regions to complete.

In the mean time, this is a simplified version of my workaround which seems ok so far:

  1. In the provider, set skip_provider_registration = true
  2. Use a local-exec provisioner to call the Azure CLI to register each provider you need (there is a resource to do this out there, but it also waits for the status to change to "Registered")
resource "null_resource" "provider_registration" {
  provisioner "local-exec" {
    command = "az provider register --namespace 'Microsoft.Compute'"
  }
}
  1. Add an explicit dependency on your resources/module calls that require a resource provider to ensure the provisioner runs first

@magodo
Copy link
Collaborator

magodo commented Sep 8, 2023

I'm not sure why it takes so long time to register RP, but you can always skip the registration via:

export ARM_PROVIDER_ENHANCED_VALIDATION=1
export ARM_SKIP_PROVIDER_REGISTRATION=true

Meanwhile, if you still want to ensure some certain RPs are registered, you can use: azurerm_resource_provider_registration.

@magodo magodo added the question label Sep 8, 2023
@sreekanth3107
Copy link
Author

this is resolved after connecting with MSFT and got responce that there is some internal issue

@amcsi
Copy link
Contributor

amcsi commented Feb 13, 2024

I ran into this issue too. I'm not sure this is going to solve it for anyone else, but for some reason the problem was caused by the fact that I created an App Registration for TF to use with my Contributor user with which I haven't created any TF resources yet.

By - through the Azure Portal - manually creating a temporary Resource Group then promptly deleting it, suddenly TF plan/apply started working.

Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants