Cloud and Datacenter Management Blog

Microsoft Hybrid Cloud blogsite about Management


Leave a comment

Microsoft Azure Resource Graph is a Powerful Tool #Azure #Cloud #AzOps #Kusto #PowerShell

Welcome to Azure Resource Graph

Azure Resource Graph is a service in Azure that is designed to extend Azure Resource Management by providing efficient and performance resource exploration with the ability to query at scale across a given set of subscriptions so that you can effectively govern your environment. Azure Resource Graph enables full visibility into your environments by providing high performance and powerful query capability across all your resources.

From here you can experience the power of Azure Resource Graph by doing it yourself.

Https://shell.azure.com

You can use Microsoft Azure Resource Graph with different language support like :

  • With Azure CLI
  • With PowerShell
  • With Kusto in Azure Resource Graph Explorer

Start here when you like to work with Microsoft Azure CLI

From here we are going further with Azure PowerShell and Azure Resource Graph in CloudShell.
Login to https://shell.azure.com

Type following command : Install-Module -Name Az.ResourceGraph

Type Y

Type the Following Command: Get-Command -Module ‘Az.ResourceGraph’ -CommandType ‘Cmdlet’

From here we can start with Search in Azure Resource Graph

The first step to understanding queries with Azure Resource Graph is a basic understanding of the Query Language. If you aren’t already familiar with Azure Data Explorer, it’s recommended to review the basics to understand how to compose requests for the resources you’re looking for.

Samples


Command : Search-AzGraph -Query ‘Resources | project name, type | limit 5’

Without the Limit 5 you get all of your resources.

Command: Search-AzGraph -Query ‘Resources | project name, type | limit 10 | order by name asc’

Command: Search-AzGraph -Query “Resources | summarize count()”


Command: Search-AzGraph -Query “Resources | project name, location, type| where type =~ ‘Microsoft.Compute/virtualMachines’ | order by name desc”

Command: Search-AzGraph -Query “Resources | where type =~ ‘Microsoft.Compute/virtualMachines’ | project name, properties.storageProfile.osDisk.osType | top 15 by name desc”


Command: Search-AzGraph -Query “Resources | where type contains ‘publicIPAdresses’ and isnotempty(properties.ipAddress) | project properties.ipAddress | limit 100”

Handy to see your External IP Addresses in Azure 😉


Command: Search-AzGraph -Query “Resources | where tags.environment=~’internal’ | project name”

To find tour Tagged Resources in Azure.


Microsoft Azure Resource Graph Explorer in the Portal.

Here you can make your kusto queries and save them for Colleagues by sharing them.

Sharing your Kusto queries

Resources
| where type =~ ‘microsoft.compute/virtualmachines’
| extend nics=array_length(properties.networkProfile.networkInterfaces)
| mv-expand nic=properties.networkProfile.networkInterfaces
| where nics == 1 or nic.properties.primary =~ ‘true’ or isempty(nic)
| project vmId = id, vmName = name, vmSize=tostring(properties.hardwareProfile.vmSize), nicId = tostring(nic.id)
| join kind=leftouter (
Resources
| where type =~ ‘microsoft.network/networkinterfaces’
| extend ipConfigsCount=array_length(properties.ipConfigurations)
| mv-expand ipconfig=properties.ipConfigurations
| where ipConfigsCount == 1 or ipconfig.properties.primary =~ ‘true’
| project nicId = id, publicIpId = tostring(ipconfig.properties.publicIPAddress.id))
on nicId
| project-away nicId1
| summarize by vmId, vmName, vmSize, nicId, publicIpId
| join kind=leftouter (
Resources
| where type =~ ‘microsoft.network/publicipaddresses’
| project publicIpId = id, publicIpAddress = properties.ipAddress)
on publicIpId
| project-away publicIpId1

More information about Microsoft Azure Resource Graph Explorer

Conclusion

When you are the Microsoft Azure Administrator, the Resource Graph Explorer can be really Powerful and fast to get the right information you are looking for. When you invest in the kusto queries your can save them and Share with your Colleagues to serve your business needs. Hope this is useful for you and happy Scripting with Kusto, Powershell or Azure CLI in the Cloud


Leave a comment

Microsoft #Azure CloudShell for Management tasks #Bash #Powershell #CLI #KubeCtl #Terraform

https://shell.azure.com

Azure Cloud Shell is an interactive, browser-accessible shell for managing Azure resources. It provides the flexibility of choosing the shell experience that best suits the way you work. Linux users can opt for a Bash experience, while Windows users can opt for PowerShell.

In this quick overview you will see the possibilities of Microsoft Azure Cloudshell functionalities and tools.

Azure Cloudshell Editor

Azure Cloud Shell includes an integrated file editor built from the open-source Monaco Editor. The Cloud Shell editor supports features such as language highlighting, the command palette, and a file explorer.
This can be handy with JSON and YAML files.

 

When you have your App YAML file for your Azure Kubernetes Cluster on your Cloud drive, you can edit the file online with your browser and save it in the Azure Cloud. I like this editor in the Cloudshell, especially when you are not behind your own laptop or pc and you have to make a quick change.

I have a Kubernetes Cluster installed on Azure and with this editor I can explore my Azure logs, Cache, and config files for the information I need to work with in Bash, Powershell to do my CLI commands for example 😉

For the Powershell Gurus 

Azure PowerShell provides a set of cmdlets that use the Azure Resource Manager model for managing your Azure resources. Learn here more about Azure Powershell

Azure Kubernetes CLI Kubectl

Kubectl is a command line interface for running commands against Kubernetes clusters. kubectl looks for a file named config in the $HOME/.kube directory. You can specify other kubeconfig files by setting the KUBECONFIG environment variable or by setting the –kubeconfig flag.
Read here more about Kubectl

Terraform CLI is Available

What is Terraform?
Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.
Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans which can be applied.
The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc.

The key features of Terraform are:

Infrastructure as Code
Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.

Execution Plans
Terraform has a “planning” step where it generates an execution plan. The execution plan shows what Terraform will do when you call apply. This lets you avoid any surprises when Terraform manipulates infrastructure.

Resource Graph
Terraform builds a graph of all your resources, and parallelizes the creation and modification of any non-dependent resources. Because of this, Terraform builds infrastructure as efficiently as possible, and operators get insight into dependencies in their infrastructure.

Change Automation
Complex changesets can be applied to your infrastructure with minimal human interaction. With the previously mentioned execution plan and resource graph, you know exactly what Terraform will change and in what order, avoiding many possible human errors.

More information on Terraform

It’s really easy to Upload or Download your Files.

AzCopy is a command-line utility designed for copying data to/from Microsoft Azure Blob, File, and Table storage, using simple commands designed for optimal performance. You can copy data between a file system and a storage account, or between storage accounts.

More information about Features & tools for Azure Cloud Shell here

Conclusion :

Microsoft Azure Cloudshell is very powerful to work with, creating your infrastructure from the Command Line Interface (CLI) or with JSON / YAML scripts. Some features or commands are not available in the Azure portal and that’s where Azure Cloudshell can help you out. Try the different Azure Cloudshell Tools and look what you like most to use for your work. From here you can work on any device with a browser and do your work. #MVPBuzz