question

WillMiller-8030 avatar image
0 Votes"
WillMiller-8030 asked

Issues with Azure Management SDK Deadlocking an await call in C#.

I am trying to build an application that Clones an Azure hosted database using the Azure.Management.Fluent SDK in C#. from the controller I am making a call to the CloneDbService CloneDB method.

 CloneDBService.CloneDB(model).Wait();

The CloneDB call is Async so I have used the Wait() method.

once I am into the actual service call I get the Azure Credentials object as well as the IAzure object with no issues.

                     AzureCredentials credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(ClientId, ClientSecret, TenantId, AzureEnvironment.AzureGlobalCloud);

                     IAzure azure = Azure
                         .Configure()
                         .Authenticate(credentials)
                         .WithSubscription(SubscriptionId);


where the issues come up is in the next section of the process where I attempt to get the SqlServer instance.

                     ISqlServer sqlServer = await azure.SqlServers.GetByResourceGroupAsync(model.SelectedOpsDatabase.ResourceGroupName, model.SelectedOpsDatabase.SQLServerName);

This call will deadlock and never finish. I have added Aggregate Exception Handling to see if I was getting an exception but it wasn't being picked up correctly.

                     catch (AggregateException ae)
                     {
                         foreach (Exception ex in ae.InnerExceptions)
                         {
                             _logger.WriteLog(ex.ToString());
                         }
                     }

but there are no errors being caught.

First I thought the issue was using the actual SDK so I attempted to do the same call with the REST API and the call still deadlocked. I am at a loss for what may be causing this any help would be appreciated.

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers