@@ -15,36 +15,41 @@ 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 - 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+ While the below sample uses the interactive login, other authentication options can be found in the [ README.md file of @azure/ms-rest-nodeauth ] ( https://www.npmjs.com/package/@azure/ms-rest-nodeauth ) package
30+ ``` typescript
31+ const msRestNodeAuth = require (" @azure/ms-rest-nodeauth" );
2932const { AuthorizationManagementClient } = require (" @azure/arm-authorization" );
30- const { interactiveLogin } = require (" @azure/ms-rest-nodeauth" );
31-
3233const subscriptionId = process .env [" AZURE_SUBSCRIPTION_ID" ];
3334
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);
35+ msRestNodeAuth .interactiveLogin ().then ((creds ) => {
36+ const client = new AuthorizationManagementClient (creds , subscriptionId );
37+ const resourceGroupName = " testresourceGroupName" ;
38+ const resourceProviderNamespace = " testresourceProviderNamespace" ;
39+ const parentResourcePath = " testparentResourcePath" ;
40+ const resourceType = " testresourceType" ;
41+ const resourceName = " testresourceName" ;
42+ const filter = " testfilter" ;
43+ client .roleAssignments .listForResource (resourceGroupName , resourceProviderNamespace , parentResourcePath , resourceType , resourceName , filter ).then ((result ) => {
44+ console .log (" The result is:" );
45+ console .log (result );
4446 });
47+ }).catch ((err ) => {
48+ console .error (err );
49+ });
4550```
4651
47- #### browser - Authentication, client creation and list classicAdministrators as an example written in JavaScript.
52+ #### browser - Authentication, client creation and listForResource roleAssignments as an example written in JavaScript.
4853
4954##### Install @azure/ms-rest-browserauth
5055
@@ -57,7 +62,6 @@ npm install @azure/ms-rest-browserauth
5762See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.
5863
5964- index.html
60-
6165``` html
6266<!DOCTYPE html>
6367<html lang =" en" >
@@ -71,27 +75,27 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to
7175 const subscriptionId = " <Subscription_Id>" ;
7276 const authManager = new msAuth.AuthManager ({
7377 clientId: " <client id for your Azure AD app>" ,
74- tenant: " <optional tenant for your organization>" ,
78+ tenant: " <optional tenant for your organization>"
7579 });
7680 authManager .finalizeLogin ().then ((res ) => {
7781 if (! res .isLoggedIn ) {
7882 // may cause redirects
7983 authManager .login ();
8084 }
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- });
85+ const client = new Azure.ArmAuthorization.AuthorizationManagementClient (res . creds , subscriptionId);
86+ const resourceGroupName = " testresourceGroupName " ;
87+ const resourceProviderNamespace = " testresourceProviderNamespace " ;
88+ const parentResourcePath = " testparentResourcePath " ;
89+ const resourceType = " testresourceType " ;
90+ const resourceName = " testresourceName " ;
91+ const filter = " testfilter " ;
92+ client . roleAssignments . listForResource (resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter). then (( result ) => {
93+ console .log (" The result is: " );
94+ console . log (result);
95+ }) .catch ((err ) => {
96+ console .log (" An error occurred:" );
97+ console .error (err);
98+ });
9599 });
96100 </script >
97101 </head >
@@ -103,4 +107,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to
103107
104108- [ Microsoft Azure SDK for Javascript] ( https://github.com/Azure/azure-sdk-for-js )
105109
106- ![ Impressions] ( https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fauthorization%2Farm -authorization%2FREADME .png )
110+ ![ Impressions] ( https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/authorization/arm -authorization/README .png )
0 commit comments