/ARMClient

A simple command line tool to invoke the Azure Resource Manager API

Primary LanguageC#Apache License 2.0Apache-2.0

ARMClient

ARMClient is a simple command line tool to invoke the Azure Resource Manager API. You can install it from Chocolatey by running:

choco install armclient

This blog post introduces the tool and is a good place to start.

Check out wiki for more details.

Login and get tokens
    ARMClient.exe login [environment name]

Call ARM api
    ARMClient.exe [get|post|put|delete] [url] [@file|json] (-verbose)

Copy token to clipboard
    ARMClient.exe token [tenant|subscription]

List token cache
    ARMClient.exe listcache

Clear token cache
    ARMClient.exe clearcache

Note: The tokens are cached at %USERPROFILE%\.arm folder. All files are encrypted with CurrentUser ProtectData .NET api.

Note: PowerShell users will need to escape the @ symbol with a back tick `.

ARMClient.Library.ARMClient

ARMClient.Library.ARMClient is a library that facilitates getting tokens and doing ARM operations. The client is used through Dynamic Typing in .NET

Example

// This example prints the names of all resourceGroups that don't
// have sites under a certain subscription

private static async Task Run()
{
    
	var armClient = await ARMLib.GetDynamicClient("2014-04-01", AzureEnvironments.Prod).ConfigureLogin(LoginType.Upn,"username","password");
            

    var resourceGroups = await armClient.Subscriptions["{subscriptionId}"]
                                        .ResourceGroups
                                        .GetAsync<JObject>();

    foreach (var resourceGroup in resourceGroups.value)
    {
        var sites = (Site[]) await armClient.Subscriptions["{subscriptionId}"]
                                            .ResourceGroups[resourceGroup.name]
                                            .Providers["Microsoft.Web"]
                                            .Sites
                                            .GetAsync<Site[]>();

        if (sites.Length == 0)
        {
            Console.WriteLine("ResourceGroup: {0} Doesn't contain any websites!",
                              resourceGroup.name);
        }
    }
}


public class Site
{
    public string location { get; set; }
    public string name { get; set; }
}

The make up of the call is similar to the way ARM Urls are constructed. For example if the Url looks like this https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{webSiteName}/slots/{slotName}/config/web

Note that you can omit the hostname, and simply have: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{webSiteName}/slots/{slotName}/config/web

then the ARMClient call will be .Subscriptions["{subscriptionId}"].ResourceGroups["{resourceGroupName}"].Providers["Microsoft.Web"].Sites["{webSiteName}"].Slots["{slotName}"].Config["web"]

Note: Capitalization is optional .Subscriptions[""] == .subscription[""] also the distinction between [] and . is also optional .Config["web"] == .Config.Web. However, some names like subscription Ids which are usually GUIDs are not valid C# identifiers so you will have to use the indexer notation.

ArmGuiClient

There is also a WPF GUI tool we create for ease of use. See ArmGuiClient help page for more details

ArmGuiClient.exe