Skip to content

Instantly share code, notes, and snippets.

@isaacrlevin
Created November 19, 2021 23:18
Show Gist options
  • Save isaacrlevin/aaf31ddc42de5f780e03377498280119 to your computer and use it in GitHub Desktop.
Save isaacrlevin/aaf31ddc42de5f780e03377498280119 to your computer and use it in GitHub Desktop.
Azure SDK
var credential = new AzureCliCredential();
ArmClient armClient = new ArmClient(credential);
var subscriptions = armClient.GetSubscriptions();
var sub = subscriptions.Where(a => a.Data.SubscriptionGuid == mySubId).FirstOrDefault();
var creds = new AzureIdentityFluentCredentialAdapter(sub.Data.TenantId, AzureEnvironment.AzureGlobalCloud);
// fails here
var websites = await Azure.Authenticate(creds)
.WithSubscription(sub.Data.DisplayName)
.WebApps.ListByResourceGroupAsync(rgName);
@jongio
Copy link

jongio commented Nov 19, 2021

Why are you using Fluent libs? You should have everything you need with the new libs. https://azure.github.io/azure-sdk/releases/latest/mgmt/dotnet.html

Try passing credential to AzureIdentityFluentCredentialAdapter

var credential = new AzureCliCredential();
ArmClient armClient = new ArmClient(credential);
var subscriptions = armClient.GetSubscriptions();
var sub = subscriptions.Where(a => a.Data.SubscriptionGuid == mySubId).FirstOrDefault();
var creds = new AzureIdentityFluentCredentialAdapter(credential, sub.Data.TenantId, AzureEnvironment.AzureGlobalCloud);

// fails here
var websites = await Azure.Authenticate(creds)
                          .WithSubscription(sub.Data.DisplayName)
                          .WebApps.ListByResourceGroupAsync(rgName);

@isaacrlevin
Copy link
Author

That doesn't seem to work either. If you have a preferred sample, I will gladly take that.

@isaacrlevin
Copy link
Author

isaacrlevin commented Nov 22, 2021 via email

@isaacrlevin
Copy link
Author

isaacrlevin commented Nov 23, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment