-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[BUG] Azure.ResourceManager.Network extension calls fail with System.MissingMethodException #27725
Comments
Thank you for your feedback. Tagging and routing to the team member best able to assist. |
I have the same issue: Azure.ResourceManager.Network version 1.0.0-beta.5
======================================================= |
Not the same method, but I am also encountering a missing method exception in System.MissingMethodException: Method not found: '!!0 Azure.ResourceManager.Resources.Subscription.UseClientContext(System.Func`5<System.Uri,Azure.Core.TokenCredential,Azure.ResourceManager.ArmClientOptions,Azure.Core.Pipeline.HttpPipeline,!!0>)'.
at Azure.ResourceManager.Network.SubscriptionExtensions.GetVirtualNetworksAsync(Subscription subscription, CancellationToken cancellationToken) |
@stishkin @Vevish @DizzyDeveloper I could not re-produce this problem. Here is my test case. using NUnit.Framework;
using Azure.ResourceManager;
using Azure.ResourceManager.Network;
using Azure.ResourceManager.Resources;
using System;
using Azure.Identity;
namespace TestNetwork2;
public class Tests
{
[SetUp]
public void Setup()
{
}
[Test]
public void Test1()
{
ArmClient armClient = new ArmClient(new DefaultAzureCredential());
var subs = armClient.GetSubscriptions();
foreach (var s in subs)
{
Console.Error.WriteLine($"Subscription: {s.Id.Name}");
ResourceGroupCollection rgs = s.GetResourceGroups();
foreach (var rg in rgs)
{
Console.Error.WriteLine($"Resource Group: {rg.Id.Name}");
try
{
var myNets = rg.GetVirtualNetworks(); //Error occurs here and any other network related requests
foreach (var mynet in myNets)
{
Console.Error.WriteLine($"Virtual Network: myNets.Id");
}
}
catch (Exception f)
{
Console.Error.WriteLine(f);
}
}
}
}
} From the error stack trace, it seems that it's a compatibility problem between What are the versions of those two packages in your I suggest to upgrade to the latest versions. |
I was using Visual Studio 2019, Upgraded to Visual 2022, and using the latest Azure.ResourceManager, i did try a fewer lower versions on visual studio 2019, unfortunately, i was not able to go to the latest on visual 2019. Moving to Visual 2022 with these package versions have resolved the issue, seems like a package mismatch like [archerzz] mentioned Thank you . Exe net6.0 |
@archerzz My issue came down to incompatibility between versions different versions of the SDK. Those two packages didn't mix very well as it was using Azure.Core 1.22 which produced that exception I mentioned earlier. Downgrading However, I have noticed you have recently release a new version for Azure.ResourceManager.Network. Havn't tried it yet, but it appears to share the same Azure.Core requirement as the latest |
@Vevish @DizzyDeveloper I'm glad the problem has been resolved for you. We're in beta and there are breaking changes between each version, so normally you have to pick up versions of different packages which are released at the same time. The compatibility issue should happen rarely after we go for GA. @stishkin Does it work for you? |
@archerzz yes, this issue is resolved after upgrade to Azure.ResourceManager.Network version 1.0.0-beta.6 |
@archerzz May I ask what happened with the |
@DizzyDeveloper Do you mean How do you use it? I think most information can be retrieved in
Here is an example of how it is used: https://cs.github.com/Azure/azure-sdk-for-net/blob/d3eb6ee84e2a42e1308f55192c74dd04e57e3240/sdk/cdn/Azure.ResourceManager.Cdn/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs#L50 |
Heya @archerzz, internal static async Task<PublicIpAddressDto> GetPublicIpAddress(this Subscription subscription, ResourceIdentifier virtualMachineScaleSetInstanceId)
{
// GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines/{virtualmachineIndex}/networkInterfaces?api-version=2018-10-01
return await subscription.UseClientContext(async (uri, credential, opt, pipe) =>
{
using (var message = pipe.CreateMessage())
{
message.Request.Method = RequestMethod.Get;
var builder = new RequestUriBuilder();
builder.Reset(uri);
builder.AppendPath(virtualMachineScaleSetInstanceId.ToString());
builder.AppendQuery("api-version", "2018-10-01");
message.Request.Uri = builder;
message.Request.Headers.Add("Accept", "application/json");
await pipe.SendAsync(message, default).ConfigureAwait(false);
using (var reader = new StreamReader(message.Response.ContentStream!))
{
var content = await reader.ReadToEndAsync().ConfigureAwait(false);
var response = JsonSerializer.Deserialize<PublicIpAddressDto>(content);
return response!;
}
}
}).ConfigureAwait(false);
} Not the grandest...but got the job done. Yea I noticed the |
The reason this was removed it breaks the immutability requirement of clients. Do I understand correctly the issue here is a point in time issue that will be resolved once we have coverage on all APIs which will be in the GA version this month? I believe if we wanted to go the route of providing raw access to all APIs we would add in low level client support which is a separate set of untyped methods but give you more low level control. |
@m-nash Yip yip I did believe that most of the scenarios were I needed to use the In the undocumented route scenario that I am referring to in my case, is a modified version of the permission rest api. On the page it documents the ability to list the "callers" permissions for a specific resource. Which I suspect will be supported by the SDK, however, as I mentioned above I am using a slighty modified version of said route. Specifically, I am needing to list all the callers permissions at the subscription level not the resource/resource group level. |
@DizzyDeveloper Low level client (or Data plane generated client) is for date plane, not for mgmt plane. |
@archerzz So would there be away for me to execute the route as I defined the previous comment?
At the moment I am invoking this manually because the SDK doesn't have a support it out of the box. Will this get added in a later release? |
@DizzyDeveloper |
@m-nash @archerzz in our case, we were using the technique described by @DizzyDeveloper in order to poll operation state on URIs such as: We get this URL from the |
@madd0 Which SDK are you using? I believe the SDK provides polling implementation. Do you want to manually poll the status of an operation?
|
We are using Track2, which does provide polling, but in our scenario, the asynchronous operation is performed by one process, which stores the polling URI in storage, and the polling is performed by another process, which only has the URI to perform the call. We used to use ValueTask SendPollingRequestTask(Uri uri, TokenCredential creds, ArmClientOptions clientOptions, HttpPipeline httpPipeline)
{
httpMessage = httpPipeline.CreateMessage();
messageInitializer(httpMessage);
return httpPipeline.SendAsync(httpMessage, ct);
}
var armClient = new ArmClient(credentials, subscriptionId, options);
await armClient.UseClientContext(SendPollingRequestTask); With private static HttpMessage InitializeHttpMessageFromOperation(SingleOperation operation, HttpMessage httpMessage)
{
Request request = httpMessage.Request;
request.Method = RequestMethod.Get;
RequestUriBuilder requestUriBuilder = new RequestUriBuilder();
requestUriBuilder.Reset(operation.PollingUri);
request.Uri = requestUriBuilder;
request.Headers.Add("Accept", "application/json");
return httpMessage;
} And As an alternative, we are now using var pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, scope));
using (var httpMessage = pipeline.CreateMessage())
{
messageInitializer(httpMessage);
await pipeline.SendAsync(httpMessage, ct);
} The builder takes the same (Disclaimer: the code approximates our actual code to give an idea of how we're using the SDK, but is not guaranteed to compile.) |
Closing since the original problem had been resolved. For the issue about polling state, let's continue the discussion in Azure/autorest.csharp#2158 Thanks. |
Library name and version
Azure.ResourceManager.Network 1.0.0-beta.5
Describe the bug
All of methods fail in a similar manner.
Expected behavior
Method call to succeed
Actual behavior
System.MissingMethodException: Method not found: 'Azure.ResourceManager.ArmClientOptions Azure.ResourceManager.Core.ArmResource.get_ClientOptions()'.
at Azure.ResourceManager.Network.VirtualNetworkCollection..ctor(ArmResource parent)
at Azure.ResourceManager.Network.ResourceGroupExtensions.GetVirtualNetworks(ResourceGroup resourceGroup)
Reproduction Steps
using Azure.ResourceManager;
using Azure.ResourceManager.Network;
Environment
No response
The text was updated successfully, but these errors were encountered: