azure-sdk-for-net: Fluent SDK doesn't run under ASP.NET in .Net 4.5.2

Guys, I might be doing something wrong, but I can’t get anything to work at all.

AzureCredentials azureCredentials = new AzureCredentials(servicePrincipalLoginInformation, TenantId, AzureEnvironment.AzureGlobalCloud);
            Azure azure = Azure.Authenticate(azureCredentials).WithSubscription(SubscriptionId) as Azure;

This is my auth code. Doesn’t return any error. After I am trying to provision a Resource group and its just stuck without any errors or anything. The same behavior for any api call. Any idea?

message.InnerText = "Resource Group Doesnt Exists " + DateTime.Now.ToShortDateString();

var groupName = SdkContext.RandomResourceName(dealerID + "_" +"rsGroup_", 24);
resourceGroup = azure.ResourceGroups
           .Define(groupName)
           .WithRegion(Region.AustraliaSouthEast)
           .Create();

message.InnerText = "Creating Resource Group " + DateTime.Now.ToShortDateString();

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 25 (8 by maintainers)

Most upvoted comments

@fredcicles Sync methods should also be fixed in the next release (shipping end of August)

@abhi1509 - FYI, just verified. CheckExistence hangs while CheckExistenceAsync works fine. here is the code:

public async Task<ActionResult> Index()
{
    var credentials = SdkContext.AzureCredentialsFactory.FromFile(Environment.GetEnvironmentVariable("AZURE_AUTH_LOCATION"));

    var azure = Azure
        .Configure()
        .WithLogLevel(HttpLoggingDelegatingHandler.Level.None)
        .Authenticate(credentials)
        .WithDefaultSubscription();

	var result = await azure.ResourceGroups.CheckExistenceAsync("somerandomnamegoeshere");
    ...
}

This issue is blocking Create scenarios where we create each dependent resource in parallel.

@hovsepm this is also broken: azure.ResourceGroups.CheckExistence(resourceGroupName));

Please try the same on a traditional ASP.NET app, not a .Net Core app, .Net Core, removed synchronization contexts and that is potentially the reason you’re not seeing this repro there.

Hello Guys, I tried different types of threading:

  • async+await
  • Task<T>
  • ThreadPool.QueueUserWorkItem
  • new Thread()

Nothing worked with MVC.NET 5.2.3) on .NET 4.5.2 with Microsoft.Azure.Management.Fluent 1.0.0.60 that I got from NuGet because of exactly the same problem: TokenCache: No matching token was found in the cache

The same code works just fine from desktop application. Is there any example projects that I can look at?