ARM Client to Deal With ARM APIs

ARMClient is a command line tool to interact with ARM APIs. In one of our previous posts we discovered that data retention period for Azure Log Analytics could be setup separately for each data type (table) but not through portal interface. ARMClient can be used for the same purpose that allows you to invoke ARM APIs and GET/SET the parameters accordingly.

Let’s see how this can be installed and then used. This can be installed on your machine by chocolatey so let’s first install choco which is a package manager for Windows and can be installed by PowerShell.

Start the PowerShell in Administrator mode and then run the following command –

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

If higher level of execution policy is already setup in your session, you may see an error but that can be ignored. You will observe some progress about the download and installation as follows –

To test that choco or chocolatey has been installed, run the following command –

PS C: choco 
chocolatey vO.10.15 
Please run choco -7 • or •choco •tcomnand> —7 • for help menu.

You can test this in command prompt too –

: \Windows 
Chocolatey ve.1e.15 
Please run •choco or 'choco for help menu.

Now, to install ARM Client, run the following command in prompt. Note that cmd also needs to be started in administrator mode.

install armclient 
hocolatey ve.Ie.15 
Installing the following packages: 
armclient 
--source=https://chocolatey.org/api/v2/ 
By installing you accept licenses for the packages. 
progress: ARMCIient 1.8. 108% 
RÆIient [Approved) 
rmclient package files install completed. performing Other installation steps. 
has successfully created a shim for AADCIient. exe 
has successfully created a shim for ARÆIient.exe 
has successfully created a shim for RDFECIient.exe 
The install of armclient was successful 
Software install location not explicitly sets could be in package or 
default install location if installer. 
hocolatey installed 1/1 packages. 
See the log for details (C:

You can test this installation also by running the command as follows –

C : \Windows \system32>ARMC1ient. exe 
RMC1ient version 1.8.e.e 
simple tool to invoke the Azure Resource Manager API 
Source code is available on https://github.com/projectkudu/ARMC1ient.

ARM Client has been installed so let’s now try to run some ARM APIs. Let’s call an API to list tables from Azure Log Analytics Workspace by running the following command from cmd prompt itself. Don’t forget to substitute your own subscription id, resource group and log analytics workspace name –

ARMClient GET /subscriptions/<Subscription ID>/resourceGroups/<Resource Group Name>/providers/Microsoft.OperationalInsights/workspaces/<Log Analytics Workspace Name>/Tables?api-version=2017-04-26-preview

After running this with my parameters, I get the result as highlighted in red rectangle as follows –

What happend?

This is fair because we have not yet logged into Azure as per ARM Client so let’s login to Azure by executing “ARMClient Login” command which pops up Azure login and after login you see something as follows which confirms that now you are logged in –

If you run the API GET command again (as mentioned above), you will receive list of all tables under the log analytics as shown below –

To change the data retention limit, you can call PUSH method of the API as follows and again don’t forget to put your own subscription, resource group and log analytics workspace parameters.

ARMClient PUT /subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/MyResourceGroupName/providers/Microsoft.OperationalInsights/workspaces/MyWorkspaceName/Tables/SecurityEvent?api-version=2017-04-26-preview
    {
        "properties": 
        {
            "retentionInDays": 730
        }
    }

There might be other ways to achieve the same by CLI, PowerShell or other APIs but learning something new is always fun and so I thought to share this ARMClient utility that personally I really enjoyed exploring.