#AzureGov Meetup & Support for ARM

February 29, 2016


Thanks for those who joined us for inaugural #AzureGov meetup on Feb 22nd. For those who could not join here is a quick update.

We talked about the services that are available in AzureGov today ( see picture below).



Note that Azure Resource Manager (ARM) is now available in AzureGov.  Why am I singling out ARM from the list above? Mainly because most of the services that are available today such as Azure Cloud Services, Azure Virtual Machines, Azure Storage are based on the classic model (also known as the Service Management Model)  ARM is the “new way” to deploy and manage the services that make up your application in Azure.  The differences between the ARM and the classic model are described here. Further note that the availability of ARM is only the first step. What we also need are the Resource Managers (RM)for various services like Compute and Storage V2 ( ARM in turn calls the necessary RM to provision a service).

Since I could not find sample code to call ARM in AzureGov, here is a code snippet that you may find handy.


using System    ;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System.Threading;
using Microsoft.Azure.Management.Resources.Models;
using Microsoft.Azure.Management.Resources;
using Microsoft.Rest;
using Microsoft.Rest.Azure;

namespace AzureGovDemo
    class Program
        # Set well-known client ID for Azure PowerShell

        private static string ClientId = "1950a258-227b-4e31-a9cf-717495945fc2";
        private static string TenantId = "XXX.onmicrosoft.com";
        private static string LoginEndpoint = "https://login.microsoftonline.com/";
        private static string ServiceManagementApiEndpoint = "https://management.core.usgovcloudapi.net/";
        private static string RedirectUri = "urn:ietf:wg:oauth:2.0:oob";
        private static string SubscriptionId = "XXXXXXXX;
        private static string AzureResourceManagerEndpoint = "https://management.usgovcloudapi.net";
        static void Main(string[] args)
            var token = GetAuthorizationHeader();
            var credentials = new Microsoft.Rest.TokenCredentials(token);
            var resourceManagerClient = new Microsoft.Azure.Management.Resources.ResourceManagementClient(new Uri(AzureResourceManagerEndpoint), credentials)
                SubscriptionId = SubscriptionId,
            Console.WriteLine("Listing resource groups. Please wait….");
            var resourceGroups = resourceManagerClient.ResourceGroups.List();
            foreach (var resourceGroup in resourceGroups)
                Console.WriteLine("Resource Group Name: " + resourceGroup.Name);
                Console.WriteLine("Resource Group Id: " + resourceGroup.Id);
                Console.WriteLine("Resource Group Location: " + resourceGroup.Location);
            Console.WriteLine("Press any key to terminate the application");

        private static string GetAuthorizationHeader()
            AuthenticationResult result = null;

            var context = new AuthenticationContext(LoginEndpoint + TenantId);

            var thread = new Thread(() =>
                result = context.AcquireToken(
                  new Uri(RedirectUri));

            thread.Name = "AquireTokenThread";

            if (result == null)
                throw new InvalidOperationException("Failed to obtain the JWT token");

            string token = result.AccessToken;
            return token;

Hope this helps and I do hope you will register for the #AzureGov meetup  here – http://www.meetup.com/DCAzureGov/

Thanks to my friend Gaurav Mantri, fellow Azure MVP and developer of Cloud Portam – www.CloudPortam.com – an excellent tool for managing Azure Services. Gaurav figured out that we need to set the well known client id for powershell.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: