Azure / azure-rest-api-specs

The source for REST API specifications for Microsoft Azure.
MIT License
2.6k stars 5.01k forks source link

`Microsoft.Subscription` - Failed to create alias subscription #21924

Open ms-zhenhua opened 1 year ago

ms-zhenhua commented 1 year ago

Hi, our customer got the following error when creating an alias subscription with the PUT API, could someone kindly help have a check?

PUT /providers/Microsoft.Subscription/aliases/c15354e0-07ea-42b5-ba43-fd024b977f92?api-version=2020-09-01 HTTP/1.1
[31566](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31566)
Host: management.azure.com
[31567](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31567)
User-Agent: Go/go1.19.3 (amd64-linux) go-autorest/v14.2.1 Azure-SDK-For-Go/v66.0.0 subscription/2020-09-01 HashiCorp Terraform/1.3.6 (+https://www.terraform.io)/ Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/dev pid-222c6c49-1b0a-5959-a213-6608f9eb8820
[31568](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31568)
Content-Length: 287
[31569](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31569)
Content-Type: application/json; charset=utf-8
[31570](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31570)
X-Ms-Authorization-Auxiliary: 
[31571](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31571)
X-Ms-Correlation-Request-Id: dbf355ac-72ff-084d-93dd-4f64d4959ace
[31572](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31572)
Accept-Encoding: gzip
[31573](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31573)
{"properties":{"displayName":"******-prod","workload":"Production","billingScope":"/providers/Microsoft.Billing/billingAccounts/******/billingProfiles/******/invoiceSections/******"}}: timestamp=2022-12-16T18:30:59.924Z
[31575](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31575)
2022-12-16T18:31:01.378Z [DEBUG] provider.terraform-provider-azurerm_v3.35.0_x5: AzureRM Response for https://management.azure.com/providers/Microsoft.Subscription/aliases/c15354e0-07ea-42b5-ba43-fd024b977f92?api-version=2020-09-01: 
[31576](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31576)
HTTP/2.0 429 Too Many Requests
[31577](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31577)
Content-Length: 191
[31578](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31578)
Cache-Control: no-cache
[31579](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31579)
Content-Type: application/json; charset=utf-8
[31580](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31580)
Date: Fri, 16 Dec 2022 18:31:00 GMT
[31581](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31581)
Expires: -1
[31582](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31582)
Mise-Correlation-Id: d8b6a649-6348-4ee2-9c1c-a076a02fc4a7
[31583](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31583)
Ms-Cv: y/zacEKzSk6sUqi2l5w1OQ.0
[31584](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31584)
Pragma: no-cache
[31585](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31585)
Request-Id: dbf355ac-72ff-084d-93dd-4f64d4959ace
[31586](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31586)
Server: Microsoft-IIS/10.0
[31587](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31587)
Strict-Transport-Security: max-age=31536000; includeSubDomains
[31588](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31588)
X-Aspnet-Version: 4.0.30319
[31589](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31589)
X-Content-Type-Options: nosniff
[31590](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31590)
X-Gsm: 1.0.0.0
[31591](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31591)
X-Ms-Correlation-Request-Id: dbf355ac-72ff-084d-93dd-4f64d4959ace
[31592](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31592)
X-Ms-Ratelimit-Remaining-Tenant-Writes: 1197
[31593](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31593)
X-Ms-Request-Id: d069f58c-f1b0-47be-bf3c-e065bbcfdef8
[31594](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31594)
X-Ms-Routing-Request-Id: EASTUS2:20221216T183101Z:d069f58c-f1b0-47be-bf3c-e065bbcfdef8
[31595](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31595)
X-Powered-By: ASP.NET
[31596](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31596)
{"error":{"code":"TooManyRequests","message":"Subscription is not created. Please try again later."},"code":"TooManyRequests","message":"Subscription is not created. Please try again later."}: timestamp=2022-12-16T18:31:01.378Z
SaurabhSharma-MSFT commented 1 year ago

@ms-zhenhua We are looking into it and get back to you for any additional information.

Architekt909 commented 1 year ago

I'm also having this problem when deploying a bicep file. Initially, I created a subscription alias and it worked just fine. I then tried to check if subscriptions are idempotent and ran the deployment of the bicep file again with the exact same parameters a few minutes after it had completed, and everything worked: nothing changed with respect to the subscription (so I guess it's idempotent). I then went and worked on some other code for a while, then tried to deploy the bicep file again: Now I'm getting that same 429 error that just simply says:

{ "status": "Failed", "error": { "code": "TooManyRequests", "message": "Subscription is not created. Please try again later." } }

I can deploy any of my other bicep files it should be noted. I can even move that initially created subscription to other management groups if I want. The weird thing is, when I deploy the bicep file via PowerShell, it just hangs for what looks like 30m and doesn't give any meaningful error result. I had to look in the portal under deployments for the management group the subscription was deployed to for details, which let me abort the deployment early.

I also get the above if I try and deploy a new subscription via my bicep file with different parameters. I now seem to be stuck with being unable to make any via deployment. It should be noted I only have 2 active MCA subscriptions and 2 disabled MCA ones using the Microsoft Azure Plan.

In case it's of any use, this is all that's in my create subscription bicep file (minus the parameter declarations):

targetScope = 'managementGroup'

//....param declarations

resource subscriptionAlias 'Microsoft.Subscription/aliases@2021-10-01' = {
  name: replace(subscriptionDisplayName, ' ', '_')
  scope: tenant()
  properties: {
    workload: workloadType
    displayName: subscriptionDisplayName
    billingScope: fullBillingScope

    additionalProperties: {
      subscriptionOwnerId: ownerId
      subscriptionTenantId: tenantId
      tags: {
        // key is the "Name" value after the : is "Value" in the portal when you view the tags
        Environment: environment
        Maintainers: maintainers
        Project: projectName
        Subscription: subscriptionDisplayName
        ProjectHash: uniqueString(projectName)
        Location: deploymentLocation
      }
    }
  }
}

And this is how I'm deploying the script with my admin account:

New-AzManagementGroupDeployment `
-Name TestSubDeployment `
>>   -Location eastus `
>>   -TemplateFile modules/createSubscription.bicep `
>>   -subscriptionDisplayName "Test Subscription" `
>>   -billingAccountId <redacted> `
>>   -billingProfileId <redacted> `
>>   -billingInvoiceSectionId <redacted> `
>>   -ownerId <redacted> `
>>   -environment Dev `
>>   -maintainers "<redacted>" `
>>   -projectName "Test Project" `
>>   -ManagementGroupId NewSubscriptions-mg

I then waited 2 hours or so and tried to manually make a subscription in the portal and was denied: I got the message " subscription is not created You can deploy resources onto your recently created subscriptions. Learn more about creating subscriptions"

When viewing that link, it says for MCA customers you can have a max of 5 subscriptions in an MCA purchased directly through Azure.com: I have 4 as mentioned: 2 active, 2 disabled (can't delete them yet, need to wait 3 days). So if this really is a "you have made too many subscriptions" problem, should I still be able to create 1 more if the limit is 5? Furthermore, shouldn't the New-AzManagementGroupDeployment command not wait like half an hour and instead be able to see that 429 error (which I can almost immediately in the portal) and abort earlier and inform me of the same message that I see in the portal? Instead, if I let it run 30m or whatever, I get this incorrect error message:

New-AzManagementGroupDeployment: 10:44:48 AM - The deployment 'TestSubDeployment' failed with error(s). Showing 1 out of 1 error(s).
Status Message: At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details. (Code: DeploymentFailed)
 - {
  "error": {
    "code": "Forbidden",
    "message": "User does not have access to the requested resource or one of its dependencies.\nIf you believe you should have access, please ensure your token 
has not expired."
  },
  "code": "Forbidden",
  "message": "User does not have access to the requested resource or one of its dependencies.\nIf you believe you should have access, please ensure your token has not expired."
} (Code:Forbidden)

CorrelationId: 423aad50-7c92-427e-b4a7-4082c0fbd7fa
salimkapadia commented 1 year ago

Any updates on this?

Architekt909 commented 1 year ago

bump, this is a pretty serious issue, one that causes substantial roadblocks with development. If it's a bug, it should be fixed. If it's working as intended, it seems there could be better documentation on this topic as well as better error information, especially deploying the actual bicep file: instead of waiting 30m or so, like I originally mentioned, the portal seems to be able to detect a problem nearly instantly so the deployment program should be able to. And ideally the error output would be more meaningful to help diagnose.

triple-it commented 11 months ago

Yes... this is very unclear. https://learn.microsoft.com/en-us/azure/cost-management-billing/manage/create-subscriptions-deploy-resources states:

When deploying ACF templates, we need at least 4 clean subs to work with in the first place?

AzySir commented 10 months ago

Yes... this is very unclear. https://learn.microsoft.com/en-us/azure/cost-management-billing/manage/create-subscriptions-deploy-resources states:

  • 5 subs max?
  • one sub per 24 hour? (That's not true I could create 2, with a maximum of 4 active subs)
  • The subs should have some consumption?
  • ....

When deploying ACF templates, we need at least 4 clean subs to work with in the first place?

Thanks for sharing that - seriously backwards by Azure... what on earth