Giter VIP home page Giter VIP logo

armclient's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.