A simple command line tool to invoke the Azure Resource Manager API
Перейти к файлу
Suwath Ch 9f32e82f64 fix popup issue 2015-09-21 15:45:33 -07:00
ARMClient.Authentication fix popup issue 2015-09-21 15:45:33 -07:00
ARMClient.Console Version 1.0.2 2015-09-18 18:27:08 -07:00
ARMClient.Library support mooncake 2015-09-08 12:40:01 -07:00
ARMClient.Library.Runner common AssemblyInfo location 2015-02-04 09:02:06 -08:00
ArmClient.Gui support mooncake 2015-09-08 12:40:01 -07:00
.gitignore Build Chocolatey package 2015-01-15 16:20:28 -08:00
ARMClient.sln Added simple GUI for ArmClient 2015-02-03 11:58:37 -08:00
BuildPackage.cmd Build Chocolatey package 2015-01-15 16:20:28 -08:00
LICENSE Initial commit 2014-08-16 21:00:43 -07:00
README.md Changed call to create DynamicClient 2015-07-18 07:42:59 +02:00

README.md

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 = 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