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 create Azure B2C tenant resource #880

Closed
pierrekhouryb opened this issue May 27, 2021 · 4 comments
Closed

Cannot create Azure B2C tenant resource #880

pierrekhouryb opened this issue May 27, 2021 · 4 comments
Labels
kind/bug Some behavior is incorrect or out of spec upstream/service
Milestone

Comments

@pierrekhouryb
Copy link

Using the reference code at:
https://www.pulumi.com/docs/reference/pkg/azure-native/azureactivedirectory/b2ctenant/#example-usage

class B2CTenantStack : Stack
{
    public B2CTenantStack()
    {
        var b2cTenant = new AzureNative.AzureActiveDirectory.B2CTenant("b2cTenant", new AzureNative.AzureActiveDirectory.B2CTenantArgs
        {
            Location = "United States",
            Properties = new AzureNative.AzureActiveDirectory.Inputs.CreateTenantRequestBodyPropertiesArgs
            {
                CountryCode = "US",
                DisplayName = "Contoso",
            },
            ResourceGroupName = "some-resource-group",
            ResourceName = "newB2Ctenant.onmicrosoft.com",
            Sku = new AzureNative.AzureActiveDirectory.Inputs.B2CResourceSKUArgs
            {
                Name =  AzureNative.AzureActiveDirectory.B2CResourceSKUName.Standard,
                Tier = AzureNative.AzureActiveDirectory.B2CResourceSKUTier.A0,
            },
        });
    }
}

Expected behavior

A B2C tenant "newB2Ctenant.onmicrosoft.com" to be successfully created in the "some-resource-group" resource group.

Current behavior

"pulumi up" outputs (details):

  pulumi:pulumi:Stack: (same)
    [urn=urn:pulumi:dev::pulumi-tuto::pulumi:pulumi:Stack::pulumi-tuto-dev]
    + azure-native:azureactivedirectory:B2CTenant: (create)
        [urn=urn:pulumi:dev::pulumi-tuto::azure-native:azureactivedirectory:B2CTenant::b2cTenant]
        [provider=urn:pulumi:dev::pulumi-tuto::pulumi:providers:azure-native::default_1_8_0::0a6f1bb6-76a8-4c46-8f2a-23bd198d3145]
        location         : "United States"
        properties       : {
            countryCode: "US"
            displayName: "Contoso"
        }
        resourceGroupName: "some-resource-group"
        resourceName     : "newB2Ctenant.onmicrosoft.com"
        sku              : {
            name: "Standard"
            tier: "A0"
        }

then, upon performing the update:

Do you want to perform this update? yes
Updating (dev)

View Live: https://app.pulumi.com/pkhoury/pulumi-tuto/dev/updates/5

     Type                                            Name             Status                  Info
     pulumi:pulumi:Stack                             pulumi-tuto-dev  **failed**              1 error
 +   └─ azure-native:azureactivedirectory:B2CTenant  b2cTenant        **creating failed**     1 error

Diagnostics:
  azure-native:azureactivedirectory:B2CTenant (b2cTenant):
    error: autorest/azure: Service returned an error. Status=404 Code="NotFound" Message="Resource with ID '12b0eb52-a521-44d1-91c9-59daf4a1d084/some-resource-group/newB2Ctenant.onmicrosoft.com' does not exist." Target="resource"

  pulumi:pulumi:Stack (pulumi-tuto-dev):
    error: update failed

Resources:
    1 unchanged

Duration: 1m13s

Steps to reproduce

  1. Create a new pulumi project
  2. Copy-paste B2CTenantStack class above in B2CTenantStack.cs
  3. Replace MyStack with B2CTenantStack in Program.cs
  4. Save all
  5. pulumi up

Context (Environment)

Trying to automate the creation of Azure B2C tenants. Per Azure feedback website it does not look like it is supported, so I got quite excited when I found the B2CTenant resource reference. Hoping this is the case, and I am just doing something wrong.

Affected feature

NA

@pierrekhouryb pierrekhouryb added the kind/bug Some behavior is incorrect or out of spec label May 27, 2021
@mikhailshilkov
Copy link
Member

Hi @pierrekhouryb thank you for reporting this

Your code actually worked fine for me - I got the resources created successfully. However, I was able to reproduce the error by changing the Location from "United States" to "europe".

I logged all the HTTP commands by running pulumi up --yes --skip-preview --v=9 --debug --logflow --logtostderr and was able to find the actual error in the logs:

{"subscriptionId":"0282681f-7a9e-424b-80b2-96babd57a8a1","id":"/subscriptions/sub/providers
/microsoft.azureactivedirectory/operations/27cbcce7-4918-46f4-a362-4759c13dd67c",
"name":"27cbcce7-4918-46f4-a362-4759c13dd67c","status":"Failed","startTime":"05/27/2021 15:28:11",
"endTime":"05/27/2021 15:28:11",
"error":{"code":"BadRequest","message":"Cannot create resource with location: 'europe'. Please use location: 'United States' to create resource for b2c directory: ''.",
"extendedDetails":{"affectsQos":false,"statusCode":400}},"properties":{"billingConfig":null,"tenantId":null}}

However, the error is then hidden by another error that comes up later. I filed this issue in the Microsoft's library that is responsible for resource creation and proper error messages there. It's either a bug in the library or in the service itself, unfortunately.

@mikhailshilkov mikhailshilkov added kind/bug Some behavior is incorrect or out of spec upstream/service and removed kind/bug Some behavior is incorrect or out of spec labels May 27, 2021
@pierrekhouryb
Copy link
Author

@mikhailshilkov thanks a lot for looking into this! So does the Location have to match a specific value? Neither "United States" nor "Europe" work for me. Happy to provide the logs if that helps.

@mikhailshilkov
Copy link
Member

I'm not at all familiar with this service, unfortunately, so I can't explain what happens here, just shared my results. I think the logs would help: either find the original Azure response yourself, or, if that's tricky, feel free to email me the logs to mikhail@pulumi.com, if you feel good about sharing them with me (there may be secret values in the file).

@pierrekhouryb
Copy link
Author

@mikhailshilkov actually, after doing a bit more digging, I realized the error was due to the value chosen as B2CTenantArgs.ResourceName not being unique... After changing to a unique value, I was indeed able to create the resource (using "United States" as Location).
Copying below the log that tipped me the right error message:

I0529 17:07:17.937118   17920 eventsink.go:78] eventSink::Infoerr(<{%reset%}>{"subscriptionId":"XXX","id":"/subscriptions/XXX/providers/microsoft.azureactivedirectory/operations/XXX","name":"XXX","status":"Failed","startTime":"05/29/2021 15:06:16","endTime":"05/29/2021 15:06:17","error":{"code":"AADB2C95054","message":"The tenant with name 
'newB2Ctenant' already exists.","extendedDetails":{"affectsQos":false,"statusCode":400}},"properties":{"billingConfig":null,"tenantId":null}}

This resolves the issue as far as I'm concerned. Thanks again for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec upstream/service
Projects
None yet
Development

No branches or pull requests

3 participants