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

Azure returning that the resource has been created, but it hasn't and is returning a 404 #1126

Open
pierskarsenbarg opened this issue Sep 7, 2021 · 10 comments
Labels
awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/bug Some behavior is incorrect or out of spec

Comments

@pierskarsenbarg
Copy link
Member

I'm trying to create a B2CTenant but I'm getting the following error message:

error: resource partially created but read failed autorest/azure: Service returned an error. Status=404 Code="NotFound" Message="Resource with ID '32b9cb2e-69be-4040-80a6-02cd6b2cc5ec/PulumiTestRG4ddb8462/pkpulumitest' does not exist." Target="resource": autorest/azure: Service returned an error. Status=404 Code="NotFound" Message="Resource with ID '32b9cb2e-69be-4040-80a6-02cd6b2cc5ec/PulumiTestRG4ddb8462/pkpulumitest' does not exist." Target="resource"

From the verbose output from an update (link) I can see that we get a 202 HTTP status back with the location but the first time we poll the location for the operation it returns 200. Subsequent GET requests return 404

Repo with code in is here: https://github.com/pierskarsenbarg/b2ctenant-demo

Code being run is here:

public MyStack()
    {
        // Create an Azure Resource Group
        var resourceGroup = new ResourceGroup("PulumiTestRG");

        var b2cTenant = new Pulumi.AzureNative.AzureActiveDirectory.B2CTenant("PulumiTest", new Pulumi.AzureNative.AzureActiveDirectory.B2CTenantArgs
        {
            Location = "Europe",
            ResourceGroupName = resourceGroup.Name,
            Properties = new Pulumi.AzureNative.AzureActiveDirectory.Inputs.CreateTenantRequestBodyPropertiesArgs
            {
                CountryCode = "europe",
                DisplayName = "pk-PulumiTest"
            },
            ResourceName = "pkpulumitest",
            Sku = new Pulumi.AzureNative.AzureActiveDirectory.Inputs.B2CResourceSKUArgs
            {
                Name = Pulumi.AzureNative.AzureActiveDirectory.B2CResourceSKUName.PremiumP1,
                Tier = Pulumi.AzureNative.AzureActiveDirectory.B2CResourceSKUTier.A0
            }
        });
    }
@pierskarsenbarg pierskarsenbarg added the kind/bug Some behavior is incorrect or out of spec label Sep 7, 2021
@mikhailshilkov
Copy link
Member

mikhailshilkov commented Sep 8, 2021

I can see the following error in the logs:

Invalid value provided for parameter 'CountryCode'.

It sounds like our error handling isn't great in this scenario as we swallowed the actual root cause.

@pierskarsenbarg
Copy link
Member Author

It looks like that error message is coming from a 200 response so it's not surprising that we don't catch it

@mikhailshilkov mikhailshilkov self-assigned this Sep 8, 2021
@mikhailshilkov mikhailshilkov removed their assignment Nov 15, 2021
@mikhailshilkov
Copy link
Member

The error message handling is actually the same issue as #880 and is caused by Azure/go-autorest#634

@mikhailshilkov mikhailshilkov added awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). and removed upstream/service labels Nov 28, 2021
@guitarrapc
Copy link

guitarrapc commented May 11, 2022

I also encout same issue. Is there any way to workaround this issue?

var rg = new Pulumi.AzureNative.Resources.ResourceGroup("foo-rg", new Pulumi.AzureNative.Resources.ResourceGroupArgs
{
    ResourceGroupName = "foo",
});

var tenant = new Pulumi.AzureNative.AzureActiveDirectory.B2CTenant("foo-b2c", new Pulumi.AzureNative.AzureActiveDirectory.B2CTenantArgs
{
    Properties = new Pulumi.AzureNative.AzureActiveDirectory.Inputs.CreateTenantRequestBodyPropertiesArgs
    {
        CountryCode = "JP",
        DisplayName = "foobarpiyopiyo123",
    },
    ResourceGroupName = rg.Name,
    ResourceName = "foobarpiyopiyo123.onmicrosoft.com",
    Sku = new Pulumi.AzureNative.AzureActiveDirectory.Inputs.B2CResourceSKUArgs
    {
        Name = Pulumi.AzureNative.AzureActiveDirectory.B2CResourceSKUName.PremiumP1,
        Tier = Pulumi.AzureNative.AzureActiveDirectory.B2CResourceSKUTier.A0,
    },
    Location = "asiapacific",
});

error message

  azure-native:azureactivedirectory:B2CTenant (foo-b2c):
    error: resource partially created but read failed autorest/azure: Service returned an error. Status=404 Code="NotFound" Message="Resource with ID 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/foo/foobarpiyopiyo123.onmicrosoft.com' does not exist." Target="resource": autorest/azure: Service returned an error. Status=404 Code="NotFound" Message="Resource with ID 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/foo/foobarpiyopiyo123.onmicrosoft.com' does not exist." Target="resource"

environment

$ pulumi about

CLI
Version      3.25.0
Go Version   go1.17.7
Go Compiler  gc

Plugins
NAME          VERSION
azure-native  1.64.0
azuread       5.22.0
dotnet        unknown

Host
OS       Microsoft Windows 10 Pro
Version  10.0.19042 Build 19042
Arch     x86_64

This project is written in dotnet (C:\Program Files\dotnet\dotnet.exe v6.0.201)

NAME                VERSION
Pulumi              3.32.1
Pulumi.AzureAD      5.22.0
Pulumi.AzureNative  1.64.0

@thuijer
Copy link

thuijer commented Jun 27, 2022

Any news on this? We really want to be able to create B2C tenants using Pulumi.

@Bobetti
Copy link

Bobetti commented Jul 13, 2022

Same situation here - same bug... need urgent solution!

@RDComeau
Copy link

I'm having the same issue as @guitarrapc. I've read the documentation for both Pulumi and Azure AD B2C Tenant, and I can't seem to crate the resource.

@gabrielchites
Copy link

Still reproducible in 2023

@MaxWroe
Copy link

MaxWroe commented Aug 13, 2023

This still appears to be broken, even using an example almost identical to the one in the docs?

        var b2CTenant = new B2CTenant($"example-b2c-{args.Configuration.Environment}",
            new B2CTenantArgs()
            {
                CountryCode = "US",
                DisplayName = "Example",
                Location = "United States",
                ResourceGroupName = args.ResourceGroupName,
                ResourceName = "pulumidevtestexample",
                Sku = new AzureNative.AzureActiveDirectory.Inputs.B2CResourceSKUArgs
                {
                    Name = AzureNative.AzureActiveDirectory.B2CResourceSKUName.PremiumP1,
                    Tier = AzureNative.AzureActiveDirectory.B2CResourceSKUTier.A0,
                },
            }, childOptions);

What is the suggested work around for this, not only does this fail with an ambiguous error but also leaves my stack in a invalid state where I can no longer delete it?

@rf-0
Copy link

rf-0 commented Oct 30, 2023

In my case the issue was due to destroying my stack but the tenant itself was actually never deleted, only the b2c resource was. Not sure how to get around this but for now all I did was to manually link the AD tenant to a new Ad B2C. (you can do this by going to the Portal -> Create new Ad B2C -> Link existing subscription)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

9 participants