Cloud Academy – Getting Started with Azure Cross-Platform CLI Automation

Cloud Academy – Getting Started with Azure Cross-Platform CLI Automation
English | Tutorial | Size: 1.93 GB


In this demonstration, we will take a look at the JSON output support in the Azure Cross-Platform (xPlat) CLI Tool. By emitting JSON from the Azure xPlat CLI Tool, we can use other JSON parsing tools, such as jsawk or jq, to filter, modify, and sort the data, reducing the need to perform onerous text parsing, and improving the output format of the data.

Transcript
One of the great things about the Azure cross-platform CLI tool is that we can emit JSON from many of the commands that are available inside of it.

So the first thing we’re going to do is call “Azure config help,” and we’re actually going to change the mode from Azure service management, which we’re currently in, over to the Azure resource manager mode. So now we’ve changed contexts into ARM successfully. Any commands that we issue from now on will be executed against the resource manager API instead of the classic service management API.

So if we call “Azure account list,” you’ll see that we get more human readable output in a tabular format from that command. Now, what’s cool is that if you want to pass data between different commands in a bash shell, you can actually emit JSON instead. So if we call “Azure account list –JSON,” you’ll see that we get the JavaScript object notation for those objects that are emitted.

Now, this command, or this parameter, rather, works on many other Azure commands, as well. So one of the key concepts in Azure resource manager is called a resource group, which contains individual resources. So if we call “Azure group list,” we’ll get a list of resource groups inside of our subscription. If we append the “–JSON” parameter onto that, you’ll actually see that we get JSON output for each of those resource groups. So the name, location, and provisioning state, as well as the tags, will be emitted as JSON, which is much easier to parse using other command line tools like JQ or the JS Awk utility that parse JSON output instead of tabular output.

As a practical example of how to use the JSON output, let’s go ahead and use the utility called JS Awk. As you can see, I’ve got JS Awk installed on my system, and so I can use that to parse these JSON objects. So I’m going to call “Azure group list –JSON,” and you’ll see the output of the command. So each of these JSON objects is a member of an outer array. So the array can be parsed using a tool like JS Awk. So if we pipe the JSON output into JS Awk, we can run JavaScript for each object that’s in the JSON array.

So let’s go ahead and just do something really simple, like “return this.name.” So the JS Awk utility is going to look at the array of JSON objects, and for each object, it’s simply going to return the name property. So let’s see what the output of that looks like. So as you can see, the JS Awk utility has returned just the name property from each object, each resource group, in this case, and it’s actually built a JSON array containing strings that represent the names of each resource group.

You can also modify objects in the pipeline using JSON, the JS Awk utility, so we can actually add another property to each of the objects. So, for example, we could call “this.company,” and set that equal to Cloud Academy. So what JS Awk is going to do is take each of the objects in this JSON pipeline, and it’s going to create a new property called “this.company.” So if we run that command, we’ll get very similar JSON output to what we had before, but if we look through the rather complicated output here, you’ll see that we have a property called “company,” and each of these resource groups in this array of objects has a new property called “company” now.

One other thing that we can do with JS Awk is to run an after script. So basically, after each object has been processed in the pipeline…so let’s go back to our earlier example of returning just the resource group names. Once we get this array of strings back, we can run what’s called an after script, and we can “return this.join,” and then we’ll basically join all these strings on a new line character.

So now what we’ve done is we’ve taken the JSON output for these resource groups, we’ve parsed it with the JS Awk utility to just return the name property, and then finally, we took that array of strings and we joined it on a new line character. So now we have just the resource group names, and we can pipe these into other Unix commands to manage them appropriately.

Table of contents
1. AZURE CROSS-PLATFORM AUTOMATION
1.1 About the Azure Cross-Platform (xPlat) CLI Tool
1.2 Demo: Azure xPlat CLI Installation, Authentication, and Subscription Management
1.3 Demo: Leveraging JSON Output in Azure xPlat CLI
1.4 Demo: Managing Azure Resource Groups with Azure xPlat CLI
2. STEP-BY-STEP: CREATE A VIRTUAL MACHINE WITH AZURE XPLAT CLI
2.1 Demo: Create Virtual Network & Subnet
2.2 Demo: Create Public IP Address & Network Interface
2.3 Demo: Create Storage Account
2.4 Demo: Find an Azure VM Image
2.5 Demo: Create the Virtual Machine

Level: Advanced
Duration: 59 m

About the author (Trevor Sullivan)
Trevor Sullivan is a Microsoft MVP for Windows PowerShell, and enjoys working with cloud and automation technologies. As a strong, vocal veteran of the Microsoft-centric IT field since 2004, Trevor has developed open source projects, provided significant amounts of product feedback, authored a large variety of training resources, and presented at IT functions including worldwide user groups and conferences.

Buy Long-term Premium Accounts To Support Me & Max Speed


RAPIDGATOR
rapidgator.net/file/18dbeea5776bcefdbcefa5f409bc26f5/Getting_Started_with_Azure_Cross_Platform_CLI_Automation.part1.rar.html
rapidgator.net/file/eab78f71b31c458e6e7eb9fabbd15ccf/Getting_Started_with_Azure_Cross_Platform_CLI_Automation.part2.rar.html
rapidgator.net/file/6d721998c79150e9b43b2db9bd64f9bf/Getting_Started_with_Azure_Cross_Platform_CLI_Automation.part3.rar.html

NITROFLARE
nitroflare.com/view/52F0136CB48241C/Getting_Started_with_Azure_Cross_Platform_CLI_Automation.part1.rar
nitroflare.com/view/CDB041D2535B942/Getting_Started_with_Azure_Cross_Platform_CLI_Automation.part2.rar
nitroflare.com/view/61AEDAD73C4F177/Getting_Started_with_Azure_Cross_Platform_CLI_Automation.part3.rar

If any links die or problem unrar, send request to goo.gl/aUHSZc

Leave a Comment