Skip to content

Commit 4062c59

Browse files
authored
Merge pull request #116582 from DCtheGeek/dmc-arg-pythoncleanup
Cleaning the Python and a few links
2 parents 1171b9f + ac4f16c commit 4062c59

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

articles/governance/resource-graph/first-query-python.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Quickstart: Your first Python query"
33
description: In this quickstart, you follow the steps to enable the Resource Graph library for Python and run your first query.
4-
ms.date: 05/26/2020
4+
ms.date: 05/27/2020
55
ms.topic: quickstart
66
---
77
# Quickstart: Run your first Resource Graph query using Python
@@ -57,17 +57,15 @@ installed.
5757
```
5858

5959
> [!NOTE]
60-
> If Python is installed for all users, this command must be run from an elevated console.
60+
> If Python is installed for all users, these commands must be run from an elevated console.
6161
6262
1. Validate that the libraries have been installed. `azure-mgmt-resourcegraph` should be **2.0.0**
6363
or higher, `azure-mgmt-resource` should be **9.0.0** or higher, and `azure-cli-core` should be
6464
**2.5.0** or higher.
6565

6666
```bash
6767
# Check each installed library
68-
pip show azure-mgmt-resourcegraph
69-
pip show azure-mgmt-resource
70-
pip show azure-cli-core
68+
pip show azure-mgmt-resourcegraph azure-mgmt-resource azure-cli-core
7169
```
7270

7371
## Run your first Resource Graph query
@@ -91,18 +89,20 @@ Resource Graph query. The query returns the first five Azure resources with the
9189
# Wrap all the work in a function
9290
def getresources( strQuery ):
9391
# Get your credentials from Azure CLI (development only!) and get your subscription list
94-
subClient = get_client_from_cli_profile(SubscriptionClient)
95-
subsRaw = [sub.as_dict() for sub in subClient.subscriptions.list()]
96-
subList = []
92+
subsClient = get_client_from_cli_profile(SubscriptionClient)
93+
subsRaw = []
94+
for sub in subsClient.subscriptions.list():
95+
subsRaw.append(sub.as_dict())
96+
subsList = []
9797
for sub in subsRaw:
98-
subList.append(sub.get('subscription_id'))
98+
subsList.append(sub.get('subscription_id'))
9999

100100
# Create Azure Resource Graph client and set options
101101
argClient = get_client_from_cli_profile(arg.ResourceGraphClient)
102102
argQueryOptions = arg.models.QueryRequestOptions(result_format="objectArray")
103103

104104
# Create query
105-
argQuery = arg.models.QueryRequest(subscriptions=subList, query=strQuery, options=argQueryOptions)
105+
argQuery = arg.models.QueryRequest(subscriptions=subsList, query=strQuery, options=argQueryOptions)
106106

107107
# Run query
108108
argResults = argClient.resources(argQuery)
@@ -147,9 +147,7 @@ the following command:
147147

148148
```bash
149149
# Remove the installed libraries from the Python environment
150-
pip uninstall azure-mgmt-resourcegraph
151-
pip uninstall azure-mgmt-resource
152-
pip uninstall azure-cli-core
150+
pip uninstall azure-mgmt-resourcegraph azure-mgmt-resource azure-cli-core
153151
```
154152

155153
## Next steps

articles/governance/resource-graph/overview.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,18 @@ For more information, see
112112

113113
Azure Resource Graph Explorer, part of Azure portal, enables running Resource Graph queries directly
114114
in Azure portal. Pin the results as dynamic charts to provide real-time dynamic information to your
115-
portal workflow. For more information, see [First query with Azure Resource Graph Explorer](first-query-portal.md).
115+
portal workflow. For more information, see [First query with Azure Resource Graph Explorer](./first-query-portal.md).
116116

117-
Resource Graph supports Azure CLI, Azure PowerShell, Azure SDK for .NET, and more. The query is
117+
Resource Graph supports Azure CLI, Azure PowerShell, Azure SDK for Python, and more. The query is
118118
structured the same for each language. Learn how to enable Resource Graph with:
119119

120-
- [Azure portal and Resource Graph Explorer](first-query-portal.md)
121-
- [Azure CLI](first-query-azurecli.md#add-the-resource-graph-extension)
122-
- [Azure PowerShell](first-query-powershell.md#add-the-resource-graph-module)
120+
- [Azure portal and Resource Graph Explorer](./first-query-portal.md)
121+
- [Azure CLI](./first-query-azurecli.md#add-the-resource-graph-extension)
122+
- [Azure PowerShell](./first-query-powershell.md#add-the-resource-graph-module)
123+
- [Python](./first-query-python.md#add-the-resource-graph-library)
123124

124125
## Next steps
125126

126-
- Run your first query by using the [Azure portal](first-query-portal.md).
127-
- Run your first query with [Azure CLI](first-query-azurecli.md).
128-
- Run your first query with [Azure PowerShell](first-query-powershell.md).
127+
- Learn more about the [query language](./concepts/query-language.md).
128+
- See the language in use in [Starter queries](./samples/starter.md).
129+
- See advanced uses in [Advanced queries](./samples/advanced.md).

0 commit comments

Comments
 (0)