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] `Azure.ResourceManager.Network GetApplicationGatewaySslPredefinedPolicy().Get()` throws a `System.ArgumentException` when parsing response JSON (ValidateResourceType)

See original GitHub issue

Library name and version

Azure.ResourceManager.Network 1.0.0-beta5

Describe the bug

Attempting to retrieve an ssl predefined policy using GetApplicationGatewaySslPredefinedPolicy().Get() throws a System.ArgumentException:

Message: 
System.ArgumentException : Invalid resource type Microsoft.Resources/resourceGroups/Microsoft.Network/default/AppGwSslPolicy20150501 expected Microsoft.Network/applicationGatewayAvailableSslOptions/predefinedPolicies

Stack Trace: 
ArmResource.ValidateResourceType(ResourceIdentifier identifier)
ArmResource.ctor(ClientContext clientContext, ResourceIdentifier id)
ArmResource.ctor(ArmResource parentOperations, ResourceIdentifier id)
ApplicationGatewaySslPredefinedPolicy.ctor(ArmResource options, ApplicationGatewaySslPredefinedPolicyData resource)
ApplicationGatewaySslPredefinedPolicy.Get(CancellationToken cancellationToken)
UnitTest1.Test1() line 26

Expected behavior

Invoking GetApplicationGatewaySslPredefinedPolicy(policyId).Get() should return a valid ApplicationGatewaySslPredefinedPolicy object.

Actual behavior

Invoking GetApplicationGatewaySslPredefinedPolicy(policyId).Get() throws the following exception:

Message: 
System.ArgumentException : Invalid resource type Microsoft.Resources/resourceGroups/Microsoft.Network/default/AppGwSslPolicy20150501 expected Microsoft.Network/applicationGatewayAvailableSslOptions/predefinedPolicies

Stack Trace: 
ArmResource.ValidateResourceType(ResourceIdentifier identifier)
ArmResource.ctor(ClientContext clientContext, ResourceIdentifier id)
ArmResource.ctor(ArmResource parentOperations, ResourceIdentifier id)
ApplicationGatewaySslPredefinedPolicy.ctor(ArmResource options, ApplicationGatewaySslPredefinedPolicyData resource)
ApplicationGatewaySslPredefinedPolicy.Get(CancellationToken cancellationToken)
UnitTest1.Test1() line 26

Reproduction Steps

Add Azure.Identity 1.5.0 and Azure.ResourceManager.Network 1.0.0-beta.5 references to project:

<PackageReference Include="Azure.Identity" Version="1.5.0" />
<PackageReference Include="Azure.ResourceManager.Network" Version="1.0.0-beta.5" />

Attempt to retrieve predefined policy using GetApplicationGatewaySslPredefinedPolicy():

ArmClient armClient = new(new DefaultAzureCredential(new DefaultAzureCredentialOptions
{
    ExcludeEnvironmentCredential = true,
    ExcludeManagedIdentityCredential = true,
    ExcludeSharedTokenCacheCredential = true,
    ExcludeVisualStudioCredential = true
}));

var subscriptionId = "<...>";

var policyName = ApplicationGatewaySslPolicyName.AppGwSslPolicy20150501.ToString();
var policyId = ApplicationGatewaySslPredefinedPolicy.CreateResourceIdentifier(subscriptionId, policyName);
var policy = armClient.GetApplicationGatewaySslPredefinedPolicy(policyId).Get();

Environment

Using Microsoft Visual Studio Enterprise 2022 (64-bit) Version 17.0.5 and targeting .NET 6.0.101.

dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.101
 Commit:    ef49f6213a

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.101\

Host (useful for support):
  Version: 6.0.1
  Commit:  3a25a7f1cc

.NET SDKs installed:
  3.1.201 [C:\Program Files\dotnet\sdk]
  3.1.301 [C:\Program Files\dotnet\sdk]
  3.1.407 [C:\Program Files\dotnet\sdk]
  5.0.104 [C:\Program Files\dotnet\sdk]
  5.0.404 [C:\Program Files\dotnet\sdk]
  6.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Yao725commented, Feb 18, 2022

Confirmed, that’s a bug, will see how to fix it. @sivetic , thanks a lot for your feedback!

0reactions
Yao725commented, Nov 2, 2022

Close this issue as we have fixed it in Azure.ResourceManager.Network 1.1.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] GetEffectiveNetworkSecurityGroups fails with Json ...
The following exception is thrown: System.Text.Json. ... Json.JsonElement.GetString() at Azure.ResourceManager.Network.Models.
Read more >
Issue with JSON input when it passes through Azure ...
Looks like JSON request is not in the required format when the Azure Gateway tries to parses the JSON input. Copy. JSON parsing...
Read more >
Azure logic apps Parse Json throws an error
Following is the JSON response and the JSON schema i provided to Parse JSON. Response [ [ { "key":"Customer_Key", "value":{ "id" ...
Read more >
Solved: Parsing JSON to get email address from Azure DevOp...
[ If I have answered your question, please Accept the post as a solution. ] [ If you like my response, please give...
Read more >
Parsing JSON GET response with special characters
I've written two decodable structs to deal with this, however the naming convention of the first item is throwing an error... Code Block....
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