Skip to content

Instantly share code, notes, and snippets.

@angellaa
Last active May 12, 2017 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angellaa/23223ed9f385e4751e0c245905091d51 to your computer and use it in GitHub Desktop.
Save angellaa/23223ed9f385e4751e0c245905091d51 to your computer and use it in GitHub Desktop.
List subscriptions with Azure Fluent API
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