question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] JSON deserialization error when creating a new `AppCertificate`

See original GitHub issue

Library name and version

Azure.ResourceManager.AppService 1.0.0

Describe the bug

AppCertificate fails with a JSON deserialization error when creating a new AppCertificate, Azure Portal shows that the certificate was created successfully and Azure Resource Manager API also returns success, but the SDK internal deserialization fails.

Expected behavior

We expect the certificate to be created successfully and the information we have created to be returned.

Actual behavior

JSON deserialization error. The resource creation itself succeeds.

Stacktrace

System.ArgumentException: Value cannot be an empty string. (Parameter 'resourceId')
   at Azure.Core.Argument.AssertNotNullOrEmpty(String value, String name)
   at Azure.Core.ResourceIdentifier..ctor(String resourceId)
   at Azure.ResourceManager.AppService.AppCertificateData.DeserializeAppCertificateData(JsonElement element)
   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

Repro code

using System.Security.Cryptography.X509Certificates;

using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.AppService;
using Azure.ResourceManager.Resources;

var armClient = new ArmClient(new AzureCliCredential());

var subscription = await armClient.GetDefaultSubscriptionAsync();

ResourceGroupResource resourceGroup = await subscription.GetResourceGroupAsync("rg-cert-test");

WebSiteResource webSite = await resourceGroup.GetWebSiteAsync("app-cert-test-01");

var certificates = resourceGroup.GetAppCertificates();

var certificate = new X509Certificate2(File.ReadAllBytes(@"cert-test.pfx"), (string?)null, X509KeyStorageFlags.Exportable);

var pfx = certificate.Export(X509ContentType.Pfx, "P@ssw0rd");

// throw exception
var result = await certificates.CreateOrUpdateAsync(Azure.WaitUntil.Completed, "cert-test-01", new AppCertificateData(webSite.Data.Location)
{
    Password = "P@ssw0rd",
    PfxBlob = pfx,
    ServerFarmId = webSite.Data.AppServicePlanId
});

Console.WriteLine(result.Value.Id);

Environment

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
BastienPerdriaucommented, Nov 15, 2022

Hi,

I have this exact same error at the moment. I hope that a new version will fix this.

However, thank tou @shibayan for the workaround you found, I will test it right away.

1reaction
xboxeercommented, Oct 25, 2022

Great to hear the workaround worked! If you have any other feedback to our Azure SDK, feel free to let us know in this survey

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON serializer creates an empty object on failed ...
DeserializeObject returns a empty object if it deserializes an empty JSON (see this unit test of github).
Read more >
[BUG] JSON deserialization error when creating a new ` ...
[BUG] JSON deserialization error when creating a new `AppCertificate` · Summary · Jobs. Handle issue_comment created event · Run details. Usage · Workflow...
Read more >
Error JSONSerialization | Apple Developer Forums
That error means that the issue is either a networking problem or an issue with the JSON data being received, rather than an...
Read more >
Failed to deserialize JSON
I am new at OutSystems and I'm trying to deserialize the content which is an attribute from an entity. However it ends in...
Read more >
Don't know the type of the Apex object to deserialize in ...
Here is the issue. My JSON parsing code looks like this: class SomeApexWrapper {. public static SomeApexWrapper getInstance(String jsonString).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found