@@ -15,36 +15,42 @@ npm install @azure/arm-authorization
1515
1616### How to use
1717
18- #### nodejs - Authentication, client creation and list classicAdministrators as an example written in TypeScript.
18+ #### nodejs - Authentication, client creation and listForResource roleAssignments as an example written in TypeScript.
1919
2020##### Install @azure/ms-rest-nodeauth
2121
22+ - Please install minimum version of ` "@azure/ms-rest-nodeauth": "^3.0.0" ` .
2223``` bash
23- npm install @azure/ms-rest-nodeauth
24+ npm install @azure/ms-rest-nodeauth@ " ^3.0.0 "
2425```
2526
2627##### Sample code
2728
28- ``` javascript
29- const { AuthorizationManagementClient } = require (" @azure/arm-authorization" );
30- const { interactiveLogin } = require (" @azure/ms-rest-nodeauth" );
31-
29+ ``` typescript
30+ import * as msRest from " @azure/ms-rest-js" ;
31+ import * as msRestAzure from " @azure/ms-rest-azure-js" ;
32+ import * as msRestNodeAuth from " @azure/ms-rest-nodeauth" ;
33+ import { AuthorizationManagementClient , AuthorizationManagementModels , AuthorizationManagementMappers } from " @azure/arm-authorization" ;
3234const subscriptionId = process .env [" AZURE_SUBSCRIPTION_ID" ];
3335
34- interactiveLogin ()
35- .then ((creds ) => {
36- const client = new AuthorizationManagementClient (creds, subscriptionId);
37- client .classicAdministrators .list ().then ((result ) => {
38- console .log (" The result is:" );
39- console .log (result);
40- });
41- })
42- .catch ((err ) => {
43- console .error (err);
36+ msRestNodeAuth .interactiveLogin ().then ((creds ) => {
37+ const client = new AuthorizationManagementClient (creds , subscriptionId );
38+ const resourceGroupName = " testresourceGroupName" ;
39+ const resourceProviderNamespace = " testresourceProviderNamespace" ;
40+ const parentResourcePath = " testparentResourcePath" ;
41+ const resourceType = " testresourceType" ;
42+ const resourceName = " testresourceName" ;
43+ const filter = " testfilter" ;
44+ client .roleAssignments .listForResource (resourceGroupName , resourceProviderNamespace , parentResourcePath , resourceType , resourceName , filter ).then ((result ) => {
45+ console .log (" The result is:" );
46+ console .log (result );
4447 });
48+ }).catch ((err ) => {
49+ console .error (err );
50+ });
4551```
4652
47- #### browser - Authentication, client creation and list classicAdministrators as an example written in JavaScript.
53+ #### browser - Authentication, client creation and listForResource roleAssignments as an example written in JavaScript.
4854
4955##### Install @azure/ms-rest-browserauth
5056
@@ -57,7 +63,6 @@ npm install @azure/ms-rest-browserauth
5763See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.
5864
5965- index.html
60-
6166``` html
6267<!DOCTYPE html>
6368<html lang =" en" >
@@ -71,27 +76,27 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to
7176 const subscriptionId = " <Subscription_Id>" ;
7277 const authManager = new msAuth.AuthManager ({
7378 clientId: " <client id for your Azure AD app>" ,
74- tenant: " <optional tenant for your organization>" ,
79+ tenant: " <optional tenant for your organization>"
7580 });
7681 authManager .finalizeLogin ().then ((res ) => {
7782 if (! res .isLoggedIn ) {
7883 // may cause redirects
7984 authManager .login ();
8085 }
81- const client = new Azure.ArmAuthorization.AuthorizationManagementClient (
82- res . creds ,
83- subscriptionId
84- ) ;
85- client . classicAdministrators
86- . list ()
87- . then (( result ) => {
88- console . log ( " The result is: " );
89- console .log (result);
90- })
91- .catch ((err ) => {
92- console .log (" An error occurred:" );
93- console .error (err);
94- });
86+ const client = new Azure.ArmAuthorization.AuthorizationManagementClient (res . creds , subscriptionId);
87+ const resourceGroupName = " testresourceGroupName " ;
88+ const resourceProviderNamespace = " testresourceProviderNamespace " ;
89+ const parentResourcePath = " testparentResourcePath " ;
90+ const resourceType = " testresourceType " ;
91+ const resourceName = " testresourceName " ;
92+ const filter = " testfilter " ;
93+ client . roleAssignments . listForResource (resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter). then (( result ) => {
94+ console .log (" The result is: " );
95+ console . log (result);
96+ }) .catch ((err ) => {
97+ console .log (" An error occurred:" );
98+ console .error (err);
99+ });
95100 });
96101 </script >
97102 </head >
@@ -103,4 +108,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to
103108
104109- [ Microsoft Azure SDK for Javascript] ( https://github.com/Azure/azure-sdk-for-js )
105110
106- ![ Impressions] ( https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fauthorization%2Farm -authorization%2FREADME .png )
111+ ![ Impressions] ( https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/authorization/arm -authorization/README .png )
0 commit comments