Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
matsest committed Mar 12, 2024
1 parent 0b113cf commit 39bef65
Showing 1 changed file with 49 additions and 24 deletions.
73 changes: 49 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -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?

Expand All @@ -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 <file> -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
Expand All @@ -35,7 +78,6 @@ az graph query -q 'Resources | project name, type | limit 5'
QUERY=$(cat <file>)
az graph query -q "$QUERY"


# Query from file using script with formatted output
./scripts/resource-graph-query.sh <file>
./scripts/resource-graph-query.sh queries/resources/resource-type-count.kql # example
Expand All @@ -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 <file> -Raw
Search-AzGraph -Query $query
```

See more details [here](https://learn.microsoft.com/en-us/azure/governance/resource-graph/first-query-powershell).

## License

Expand Down

0 comments on commit 39bef65

Please sign in to comment.