[BUG] JSON deserialization error when creating a new `AppCertificate`
See original GitHub issueLibrary 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:
- Created a year ago
- Reactions:1
- Comments:8 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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