Last active
May 12, 2017 14:12
-
-
Save angellaa/23223ed9f385e4751e0c245905091d51 to your computer and use it in GitHub Desktop.
List subscriptions with Azure Fluent API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Azure.Management.Fluent; | |
using Microsoft.Azure.Management.ResourceManager.Fluent; | |
using System; | |
namespace PlayWithAzure | |
{ | |
public class Program | |
{ | |
public static void Main() | |
{ | |
string clientId = "???"; | |
string clientSecret = "???"; | |
string tenantId = "???"; | |
var cred = SdkContext.AzureCredentialsFactory.FromServicePrincipal(clientId, clientSecret, tenantId, AzureEnvironment.AzureGlobalCloud); | |
var authenticated = Azure.Authenticate(cred); | |
Console.WriteLine("Subscriptions: "); | |
foreach (var subscription in authenticated.Subscriptions.List()) | |
{ | |
Console.WriteLine(subscription.DisplayName); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment