Skip to content

Commit 2329d70

Browse files
authored
Merge pull request #200530 from v-jiaodi/jd/workitem-1766063
Update file with latest SDK
2 parents 69e58cf + aad7aed commit 2329d70

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,26 @@ works wherever JavaScript can be used, including [bash on Windows 10](/windows/w
4747
1. Add a reference to the Azure authentication library.
4848

4949
```bash
50-
npm install @azure/ms-rest-nodeauth
50+
npm install @azure/identity
5151
```
5252

5353
> [!NOTE]
54-
> Verify in _package.json_ `@azure/arm-resourcegraph` is version **2.0.0** or higher and
55-
> `@azure/ms-rest-nodeauth` is version **3.0.3** or higher.
54+
> Verify in _package.json_ `@azure/arm-resourcegraph` is version **4.2.1** or higher and
55+
> `@azure/identity` is version **2.0.4** or higher.
5656
5757
## Query the Resource Graph
5858

5959
1. Create a new file named _index.js_ and enter the following code.
6060

6161
```javascript
6262
const argv = require("yargs").argv;
63-
const authenticator = require("@azure/ms-rest-nodeauth");
64-
const resourceGraph = require("@azure/arm-resourcegraph");
63+
const { DefaultAzureCredential } = require("@azure/identity");
64+
const { ResourceGraphClient } = require("@azure/arm-resourcegraph");
6565

6666
if (argv.query) {
6767
const query = async () => {
68-
const credentials = await authenticator.interactiveLogin();
69-
const client = new resourceGraph.ResourceGraphClient(credentials);
68+
const credentials = new DefaultAzureCredential();
69+
const client = new ResourceGraphClient(credentials);
7070
const result = await client.resources(
7171
{
7272
query: argv.query
@@ -133,7 +133,7 @@ top five results.
133133
If you wish to remove the installed libraries from your application, run the following command.
134134

135135
```bash
136-
npm uninstall @azure/arm-resourcegraph @azure/ms-rest-nodeauth yargs
136+
npm uninstall @azure/arm-resourcegraph @azure/identity yargs
137137
```
138138

139139
## Next steps

0 commit comments

Comments
 (0)