Azure .NET API - MissingMethodException

411 views Asked by At

I've a problem since many days.

I'm using the Azure.Fluent package in my program and I must to create a ResourceGroup, but when I create it or list themw, I got the MissingMethodsException and I don't know why. And I've never founded any solution to this.

This is my code :

            AzureCredentials cred = SdkContext
            .AzureCredentialsFactory
            .FromServicePrincipal(
                ClientId, 
                ServicePrincipalPassword, 
                AzureTenantId, 
                AzureEnvironment.AzureGlobalCloud
            );

        var azure = Azure
            .Configure()
            .Authenticate(cred)
            .WithSubscription(AzureSubscriptionId);

        var resourceGroup = azure.ResourceGroups.List();

Thanks in advance !

EDIT

This is the detailed error I have :

System.MissingMethodException: 'Méthode introuvable : 'System.Threading.Tasks.Task`1 Microsoft.Rest.Azure.Authentication.UserTokenProvider.LoginSilentAsync(System.String, System.String, System.String, System.String, Microsoft.Rest.Azure.Authentication.ActiveDirectoryServiceSettings, Microsoft.IdentityModel.Clients.ActiveDirectory.TokenCache)'.'

2

There are 2 answers

3
Joey Cai On

I test it well in my site with Microsoft.Azure.Management.Fluent version 1.10.0 and Microsoft.Azure.Management.ResourceManager.Fluent version 1.10.0.

And create and list resourcegroup with the following code:

var credentials = SdkContext.AzureCredentialsFactory.FromFile(@"D:\azurecred.txt"); //get azure credentials from file
var azure = Azure
    .Configure()
    .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
    .Authenticate(credentials)
    .WithDefaultSubscription();
var account = azure.StorageAccounts.List();
var rg = azure.ResourceGroups.Create();
var resourceGrouplist = azure.ResourceGroups.List();

The credential contains clinetid, clientkey, tenantid and subscriptionid.

If you still have any problem, please show me more detailed information like what your fluent SDK version and you use .net or .net core and so on.

0
hovsepm On

This issue was fixed in Azure Fluent SDK a while ago. Please reference latest (v.1.18.0 at the moment) nuget packages.