From 39bef6573b4b43641f97fd045cf262201856f4cb Mon Sep 17 00:00:00 2001 From: Mats Estensen Date: Tue, 12 Mar 2024 21:03:26 +0100 Subject: [PATCH] docs: update README --- README.md | 73 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 8eee74b..84514b2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,23 @@ -# Azure Resource Graph - -A demo repository for [Azure Resource Graph](https://learn.microsoft.com/en-us/azure/governance/resource-graph/overview) with focus creating and running queries using Azure PowerShell and Azure CLI with local development in VS Code. +# Azure Resource Graph 🔎 + +A repository for [Azure Resource Graph](https://learn.microsoft.com/en-us/azure/governance/resource-graph/overview) with focus on creating and running queries using Azure PowerShell and Azure CLI with local VS Code support. + +This purpose of this repository is two-fold - to serve as a reference repository for myself and others while working with Azure Resource Graph - and to share own content related to Azure Resource Graph. + +> [!TIP] +>### 📰 Blog posts +> +> With the work in this repository I am aiming at producing a series of blog posts on [my personal blog](https://www.mxe.no). To get notice of posts you can subscribe to the [site RSS feed](https://www.mxe.no/posts/index.xml) or follow updates in this repository. +> +> The current goal is to produce the following posts to companion this repository (items without links are not published yet): +> +> 1. Why Azure Resource Graph +> 2. Basic KQL and Resource Graph Queries +> 3. Advanced Resource Graph Queries +> 4. Sharing Resource Graph Queries in Azure +> 5. Automating Resource Graph Queries +> +> Disclaimer: This might be subject to change as I go along. No dates for publishing promised :wink: ## What is Azure Resource Graph? @@ -11,15 +28,41 @@ The knowledge of resource graph and KQL is an extremely powerful skill-set when For an introduction to KQL basics in Azure I recommend the MS Learn learning path [here](https://learn.microsoft.com/en-us/training/paths/analyze-monitoring-data-with-kql/). -## Prerequisities +## Usage + +### Prerequisities + + The following prerequisites are recommended to get started with using the code provided in this repository. - [VS Code](https://code.visualstudio.com/download) - Install [recommended extensions](./.vscode/extensions.json) -- [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) - [Azure PowerShell](https://learn.microsoft.com/en-us/powershell/azure/install-azure-powershell) +- [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) - [Reader role](https://learn.microsoft.com/en-us/azure/governance/resource-graph/overview#permissions-in-azure-resource-graph) in your Azure environment -## Azure CLI +> [!NOTE] +> Azure Resource Graph does not require Azure CLI *and* Azure PowerShell. Based on what you're used to and what you are working with you can choose what to use. Both tools work on all platforms. From my side my main tool is Azure PowerShell (running on Linux! :penguin:) as I like the object-based, structured output it offers. + +### Azure PowerShell + +```powershell +# Login +Connect-AzAccount + +# Install module +Install-Module -Name Az.ResourceGraph + +# In-line query +Search-AzGraph -Query 'Resources | project name, type | limit 5' + +# Query from file +$query = Get-Content -Path -Raw +Search-AzGraph -Query $query +``` + +See more details [here](https://learn.microsoft.com/en-us/azure/governance/resource-graph/first-query-powershell). + +### Azure CLI ```bash # Login @@ -35,7 +78,6 @@ az graph query -q 'Resources | project name, type | limit 5' QUERY=$(cat ) az graph query -q "$QUERY" - # Query from file using script with formatted output ./scripts/resource-graph-query.sh ./scripts/resource-graph-query.sh queries/resources/resource-type-count.kql # example @@ -44,24 +86,7 @@ az graph query -q "$QUERY" See more details [here](https://learn.microsoft.com/en-us/azure/governance/resource-graph/first-query-azurecli). -## Azure PowerShell - -```powershell -# Login -Connect-AzAccount - -# Install module -Install-Module -Name Az.ResourceGraph - -# In-line query -Search-AzGraph -Query 'Resources | project name, type | limit 5' - -# Query from file -$query = Get-Content -Path -Raw -Search-AzGraph -Query $query -``` -See more details [here](https://learn.microsoft.com/en-us/azure/governance/resource-graph/first-query-powershell). ## License