Skip to content

[BUG] Create Managed Certificate failed with status code 202 #46854

Open
@kaibocai

Description

Library name and version

Azure.ResourceManager.AppService 1.2.0

Describe the bug

I use below code to create a managed certificate but I encounter error

2024-10-27T22:23:57Z   [Error]   Failed to create managed cert
2024-10-27T22:23:57Z   [Error]   Service request failed.
Status: 202 (Accepted)

Service request succeeded. Response content and headers are not included to avoid logging sensitive data.
2024-10-27T22:23:57Z   [Error]      at Azure.ResourceManager.AppService.CertificatesRestOperations.CreateOrUpdateAsync(String subscriptionId, String resourceGroupName, String name, AppCertificateData data, CancellationToken cancellationToken)
   at Azure.ResourceManager.AppService.AppCertificateCollection.CreateOrUpdateAsync(WaitUntil waitUntil, String name, AppCertificateData data, CancellationToken cancellationToken)

The code is

            ResourceGroupResource resourceGroupResource =
                this.client.GetDtmbResourceGroupResource(stamp.ManagedSubscriptionId, stamp.ResourceGroupName);
            AppCertificateCollection collection = resourceGroupResource.GetAppCertificates();

            string name = $"{req.DtsEnvName}-cert";
            string hostName = req.DomainName;
            //DomainNameGenerator.GenerateDomainName(req.DtsEnvName, req.Location, this.dnsConfig.DnsZoneName);
            AppCertificateData data = new(new AzureLocation(req.Location))
            {
                // HostNames = { hostName },
                CanonicalName = hostName, 
                ServerFarmId = new ResourceIdentifier(req.AspResourceId),
            };

            ArmOperation<AppCertificateResource> lro =
                await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data);
            AppCertificateResource result = lro.Value;
            AppCertificateData resourceData = result.Data;

Noticed the error code is 202, I don't really see what this error happen as it's supposed to be a long running/async operation, I am using

            ArmOperation<AppCertificateResource> lro =
                await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data);

with WaitUntil.Completed set, it should wait till the long running operation finished, but it's not.

Later I checked on the azure portal, I saw that the cert was created successfully. So I don't know why my code gives error, it should await and return succeed.

Expected behavior

The code should work synchronously to create a managed certificate.

Actual behavior

Gives error

2024-10-27T22:23:57Z   [Error]   Failed to create managed cert
2024-10-27T22:23:57Z   [Error]   Service request failed.
Status: 202 (Accepted)

Service request succeeded. Response content and headers are not included to avoid logging sensitive data.
2024-10-27T22:23:57Z   [Error]      at Azure.ResourceManager.AppService.CertificatesRestOperations.CreateOrUpdateAsync(String subscriptionId, String resourceGroupName, String name, AppCertificateData data, CancellationToken cancellationToken)
   at Azure.ResourceManager.AppService.AppCertificateCollection.CreateOrUpdateAsync(WaitUntil waitUntil, String name, AppCertificateData data, CancellationToken cancellationToken)

Reproduction Steps

try out below code

            ResourceGroupResource resourceGroupResource =
                this.client.GetDtmbResourceGroupResource(stamp.ManagedSubscriptionId, stamp.ResourceGroupName);
            AppCertificateCollection collection = resourceGroupResource.GetAppCertificates();

            string name = $"{req.DtsEnvName}-cert";
            string hostName = req.DomainName;
            //DomainNameGenerator.GenerateDomainName(req.DtsEnvName, req.Location, this.dnsConfig.DnsZoneName);
            AppCertificateData data = new(new AzureLocation(req.Location))
            {
                // HostNames = { hostName },
                CanonicalName = hostName, 
                ServerFarmId = new ResourceIdentifier(req.AspResourceId),
            };

            ArmOperation<AppCertificateResource> lro =
                await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data);
            AppCertificateResource result = lro.Value;
            AppCertificateData resourceData = result.Data;

Environment

.NET SDK:
 Version:           8.0.403
 Commit:            c64aa40a71
 Workload version:  8.0.400-manifests.e99c892e
 MSBuild version:   17.11.9+a69bbaaf5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.403\

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
 [aspire]
   Installation Source: VS 17.11.35327.3
   Manifest Version:    8.1.0/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.1.0\WorkloadManifest.json
   Install Type:        FileBased


Host:
  Version:      8.0.10
  Architecture: x64
  Commit:       81cabf2857

.NET SDKs installed:
  3.1.426 [C:\Program Files\dotnet\sdk]
  5.0.408 [C:\Program Files\dotnet\sdk]
  6.0.135 [C:\Program Files\dotnet\sdk]
  6.0.321 [C:\Program Files\dotnet\sdk]
  6.0.427 [C:\Program Files\dotnet\sdk]
  7.0.120 [C:\Program Files\dotnet\sdk]
  8.0.306 [C:\Program Files\dotnet\sdk]
  8.0.403 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

App ServicesMgmtThis issue is related to a management-plane library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions