From 43c5bc43ee49d053c55a38085dd286c588abeecb Mon Sep 17 00:00:00 2001 From: colawwj <70128817+colawwj@users.noreply.github.com> Date: Thu, 8 Jul 2021 09:07:31 +0800 Subject: [PATCH] identity support 40 (#16255) --- .../README.md | 113 +++++++++-------- .../package.json | 9 +- .../src/monitorManagementClient.ts | 10 +- .../src/monitorManagementClientContext.ts | 14 ++- .../README.md | 111 +++++++++-------- .../package.json | 9 +- .../src/monitorManagementClient.ts | 10 +- .../src/monitorManagementClientContext.ts | 14 ++- sdk/monitor/arm-monitor/README.md | 109 ++++++++-------- sdk/monitor/arm-monitor/package.json | 9 +- .../src/monitorManagementClient.ts | 10 +- .../src/monitorManagementClientContext.ts | 14 ++- sdk/msi/arm-msi/README.md | 108 ++++++++-------- sdk/msi/arm-msi/package.json | 9 +- .../src/managedServiceIdentityClient.ts | 10 +- .../managedServiceIdentityClientContext.ts | 14 ++- sdk/mysql/arm-mysql/README.md | 112 +++++++++-------- sdk/mysql/arm-mysql/package.json | 9 +- .../arm-mysql/src/mySQLManagementClient.ts | 10 +- .../src/mySQLManagementClientContext.ts | 14 ++- .../README.md | 117 ++++++++++-------- .../package.json | 9 +- .../src/networkManagementClient.ts | 10 +- .../src/networkManagementClientContext.ts | 14 ++- .../README.md | 111 +++++++++-------- .../package.json | 9 +- .../src/networkManagementClient.ts | 10 +- .../src/networkManagementClientContext.ts | 14 ++- .../arm-notificationhubs/README.md | 108 ++++++++-------- .../arm-notificationhubs/package.json | 9 +- .../src/notificationHubsManagementClient.ts | 10 +- ...notificationHubsManagementClientContext.ts | 14 ++- .../arm-operationalinsights/README.md | 108 ++++++++-------- .../arm-operationalinsights/package.json | 9 +- .../operationalInsightsManagementClient.ts | 10 +- ...rationalInsightsManagementClientContext.ts | 14 ++- .../arm-operations/README.md | 115 +++++++++-------- .../arm-operations/package.json | 9 +- .../src/operationsManagementClient.ts | 10 +- .../src/operationsManagementClientContext.ts | 14 ++- 40 files changed, 833 insertions(+), 609 deletions(-) diff --git a/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/README.md b/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/README.md index 5541c2706873..b0cccb154677 100644 --- a/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/README.md +++ b/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/README.md @@ -1,93 +1,103 @@ ## Azure MonitorManagementClient SDK for JavaScript -This package contains an isomorphic SDK for MonitorManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for MonitorManagementClient. ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge, and Firefox. -### How to Install +### Prerequisites +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/arm-monitor-profile-2019-03-01-hybrid` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/arm-monitor-profile-2019-03-01-hybrid +npm install --save @azure/arm-monitor-profile-2019-03-01-hybrid @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list metricDefinitions as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -```bash -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list metricDefinitions as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { MonitorManagementClient, MonitorManagementModels, MonitorManagementMappers } from "@azure/arm-monitor-profile-2019-03-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { MonitorManagementClient } = require("@azure/arm-monitor-profile-2019-03-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new MonitorManagementClient(creds, subscriptionId); - const resourceUri = "testresourceUri"; - const metricnamespace = "testmetricnamespace"; - client.metricDefinitions.list(resourceUri, metricnamespace).then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new MonitorManagementClient(creds, subscriptionId); +const resourceUri = "testresourceUri"; +const metricnamespace = "testmetricnamespace"; +client.metricDefinitions.list(resourceUri, metricnamespace).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list metricDefinitions as an example written in JavaScript. +#### browser - Authentication, client creation, and list metricDefinitions as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-monitor-profile-2019-03-01-hybrid sample - - + @@ -99,5 +109,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fmonitor%2Farm-monitor-profile-2019-03-01-hybrid%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/README.png) diff --git a/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/package.json b/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/package.json index d274ca5e8069..fcd2f1eada5d 100644 --- a/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/package.json +++ b/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-monitor-profile-2019-03-01-hybrid", "author": "Microsoft Corporation", "description": "MonitorManagementClient Library with typescript type definitions for node.js and browser.", - "version": "1.0.0", + "version": "1.1.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.3.2", - "@azure/ms-rest-js": "^1.8.1", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -21,7 +22,7 @@ "module": "./esm/monitorManagementClient.js", "types": "./esm/monitorManagementClient.d.ts", "devDependencies": { - "typescript": "^3.1.1", + "typescript": "^3.6.0", "rollup": "^0.66.2", "rollup-plugin-node-resolve": "^3.4.0", "rollup-plugin-sourcemaps": "^0.4.2", diff --git a/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/src/monitorManagementClient.ts b/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/src/monitorManagementClient.ts index a84f753e3fe5..0cbf7f67005e 100644 --- a/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/src/monitorManagementClient.ts +++ b/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/src/monitorManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -26,10 +27,15 @@ class MonitorManagementClient extends MonitorManagementClientContext { /** * Initializes a new instance of the MonitorManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.MonitorManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, options?: Models.MonitorManagementClientOptions) { super(credentials, options); this.metricDefinitions = new operations.MetricDefinitions(this); this.metrics = new operations.Metrics(this); diff --git a/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/src/monitorManagementClientContext.ts b/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/src/monitorManagementClientContext.ts index 72abeb1f8294..e8bec3c05d7d 100644 --- a/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/src/monitorManagementClientContext.ts +++ b/sdk/monitor/arm-monitor-profile-2019-03-01-hybrid/src/monitorManagementClientContext.ts @@ -10,20 +10,26 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-monitor-profile-2019-03-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class MonitorManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; /** * Initializes a new instance of the MonitorManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.MonitorManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, options?: Models.MonitorManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/README.md b/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/README.md index 0ca4713df7df..7d6b556b862f 100644 --- a/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/README.md +++ b/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/README.md @@ -1,94 +1,103 @@ ## Azure MonitorManagementClient SDK for JavaScript -This package contains an isomorphic SDK for MonitorManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for MonitorManagementClient. ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge, and Firefox. -### How to Install +### Prerequisites +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/arm-monitor-profile-2020-09-01-hybrid` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/arm-monitor-profile-2020-09-01-hybrid +npm install --save @azure/arm-monitor-profile-2020-09-01-hybrid @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list metricDefinitions as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list metricDefinitions as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { MonitorManagementClient, MonitorManagementModels, MonitorManagementMappers } from "@azure/arm-monitor-profile-2020-09-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { MonitorManagementClient } = require("@azure/arm-monitor-profile-2020-09-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new MonitorManagementClient(creds, subscriptionId); - const resourceUri = "testresourceUri"; - const metricnamespace = "testmetricnamespace"; - client.metricDefinitions.list(resourceUri, metricnamespace).then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new MonitorManagementClient(creds, subscriptionId); +const resourceUri = "testresourceUri"; +const metricnamespace = "testmetricnamespace"; +client.metricDefinitions.list(resourceUri, metricnamespace).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list metricDefinitions as an example written in JavaScript. +#### browser - Authentication, client creation, and list metricDefinitions as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-monitor-profile-2020-09-01-hybrid sample - - + diff --git a/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/package.json b/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/package.json index d9354f56c467..56a5df5060ad 100644 --- a/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/package.json +++ b/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-monitor-profile-2020-09-01-hybrid", "author": "Microsoft Corporation", "description": "MonitorManagementClient Library with typescript type definitions for node.js and browser.", - "version": "1.0.0", + "version": "1.1.0", "dependencies": { - "@azure/ms-rest-azure-js": "^2.0.1", - "@azure/ms-rest-js": "^2.0.4", + "@azure/ms-rest-azure-js": "^2.1.0", + "@azure/ms-rest-js": "^2.2.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.10.0" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/monitorManagementClient.js", "types": "./esm/monitorManagementClient.d.ts", "devDependencies": { - "typescript": "^3.5.3", + "typescript": "^3.6.0", "rollup": "^1.18.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-sourcemaps": "^0.4.2", diff --git a/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/src/monitorManagementClient.ts b/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/src/monitorManagementClient.ts index a84f753e3fe5..0cbf7f67005e 100644 --- a/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/src/monitorManagementClient.ts +++ b/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/src/monitorManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -26,10 +27,15 @@ class MonitorManagementClient extends MonitorManagementClientContext { /** * Initializes a new instance of the MonitorManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.MonitorManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, options?: Models.MonitorManagementClientOptions) { super(credentials, options); this.metricDefinitions = new operations.MetricDefinitions(this); this.metrics = new operations.Metrics(this); diff --git a/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/src/monitorManagementClientContext.ts b/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/src/monitorManagementClientContext.ts index 9e357d10e244..c467ad8e9122 100644 --- a/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/src/monitorManagementClientContext.ts +++ b/sdk/monitor/arm-monitor-profile-2020-09-01-hybrid/src/monitorManagementClientContext.ts @@ -10,20 +10,26 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-monitor-profile-2020-09-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class MonitorManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; /** * Initializes a new instance of the MonitorManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.MonitorManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, options?: Models.MonitorManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/monitor/arm-monitor/README.md b/sdk/monitor/arm-monitor/README.md index 04373a170952..34c0456e346b 100644 --- a/sdk/monitor/arm-monitor/README.md +++ b/sdk/monitor/arm-monitor/README.md @@ -1,92 +1,101 @@ ## Azure MonitorManagementClient SDK for JavaScript -This package contains an isomorphic SDK for MonitorManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for MonitorManagementClient. ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge, and Firefox. -### How to Install +### Prerequisites +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/arm-monitor` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/arm-monitor +npm install --save @azure/arm-monitor @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and listByResourceGroup autoscaleSettings as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and listByResourceGroup autoscaleSettings as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { MonitorManagementClient, MonitorManagementModels, MonitorManagementMappers } from "@azure/arm-monitor"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { MonitorManagementClient } = require("@azure/arm-monitor"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new MonitorManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - client.autoscaleSettings.listByResourceGroup(resourceGroupName).then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new MonitorManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +client.autoscaleSettings.listByResourceGroup(resourceGroupName).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and listByResourceGroup autoscaleSettings as an example written in JavaScript. +#### browser - Authentication, client creation, and listByResourceGroup autoscaleSettings as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-monitor sample - - + @@ -98,4 +107,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fmonitor%2Farm-monitor%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/monitor/arm-monitor/README.png) diff --git a/sdk/monitor/arm-monitor/package.json b/sdk/monitor/arm-monitor/package.json index 2b40038fbd88..aa2917699e69 100644 --- a/sdk/monitor/arm-monitor/package.json +++ b/sdk/monitor/arm-monitor/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-monitor", "author": "Microsoft Corporation", "description": "MonitorManagementClient Library with typescript type definitions for node.js and browser.", - "version": "6.0.0", + "version": "6.1.0", "dependencies": { - "@azure/ms-rest-azure-js": "^2.0.1", - "@azure/ms-rest-js": "^2.0.4", + "@azure/ms-rest-azure-js": "^2.1.0", + "@azure/ms-rest-js": "^2.2.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.10.0" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/monitorManagementClient.js", "types": "./esm/monitorManagementClient.d.ts", "devDependencies": { - "typescript": "^3.5.3", + "typescript": "^3.6.0", "rollup": "^1.18.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-sourcemaps": "^0.4.2", diff --git a/sdk/monitor/arm-monitor/src/monitorManagementClient.ts b/sdk/monitor/arm-monitor/src/monitorManagementClient.ts index a498d7b03d34..8f76eb98ccbb 100644 --- a/sdk/monitor/arm-monitor/src/monitorManagementClient.ts +++ b/sdk/monitor/arm-monitor/src/monitorManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -41,11 +42,16 @@ class MonitorManagementClient extends MonitorManagementClientContext { /** * Initializes a new instance of the MonitorManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The Azure subscription Id. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.MonitorManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.MonitorManagementClientOptions) { super(credentials, subscriptionId, options); this.autoscaleSettings = new operations.AutoscaleSettings(this); this.operations = new operations.Operations(this); diff --git a/sdk/monitor/arm-monitor/src/monitorManagementClientContext.ts b/sdk/monitor/arm-monitor/src/monitorManagementClientContext.ts index aacdc007667d..3212c44711f3 100644 --- a/sdk/monitor/arm-monitor/src/monitorManagementClientContext.ts +++ b/sdk/monitor/arm-monitor/src/monitorManagementClientContext.ts @@ -10,22 +10,28 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-monitor"; -const packageVersion = "5.4.0"; +const packageVersion = "6.1.0"; export class MonitorManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; /** * Initializes a new instance of the MonitorManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The Azure subscription Id. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.MonitorManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.MonitorManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/msi/arm-msi/README.md b/sdk/msi/arm-msi/README.md index c3f9cb728ff3..f4e16fd5e9a5 100644 --- a/sdk/msi/arm-msi/README.md +++ b/sdk/msi/arm-msi/README.md @@ -1,89 +1,100 @@ ## Azure ManagedServiceIdentityClient SDK for JavaScript -This package contains an isomorphic SDK for ManagedServiceIdentityClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ManagedServiceIdentityClient. ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge, and Firefox. -### How to Install +### Prerequisites -``` -npm install @azure/arm-msi +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/arm-msi` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: +```bash +npm install --save @azure/arm-msi @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -``` -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```ts -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { ManagedServiceIdentityClient, ManagedServiceIdentityModels, ManagedServiceIdentityMappers } from "@azure/arm-msi"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { ManagedServiceIdentityClient } = require("@azure/arm-msi"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ManagedServiceIdentityClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new ManagedServiceIdentityClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -``` -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-msi sample - - + @@ -95,5 +106,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fmsi%2Farm-msi%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/msi/arm-msi/README.png) diff --git a/sdk/msi/arm-msi/package.json b/sdk/msi/arm-msi/package.json index fde1b3ef62bb..03f9c73d485c 100644 --- a/sdk/msi/arm-msi/package.json +++ b/sdk/msi/arm-msi/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-msi", "author": "Microsoft Corporation", "description": "ManagedServiceIdentityClient Library with typescript type definitions for node.js and browser.", - "version": "1.1.0", + "version": "1.2.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.1.0", - "@azure/ms-rest-js": "^1.1.0", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/managedServiceIdentityClient.js", "types": "./esm/managedServiceIdentityClient.d.ts", "devDependencies": { - "typescript": "^3.1.1", + "typescript": "^3.6.0", "rollup": "^0.66.2", "rollup-plugin-node-resolve": "^3.4.0", "uglify-js": "^3.4.9" diff --git a/sdk/msi/arm-msi/src/managedServiceIdentityClient.ts b/sdk/msi/arm-msi/src/managedServiceIdentityClient.ts index 2360b79199a9..75e4af9098c7 100644 --- a/sdk/msi/arm-msi/src/managedServiceIdentityClient.ts +++ b/sdk/msi/arm-msi/src/managedServiceIdentityClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -22,11 +23,16 @@ class ManagedServiceIdentityClient extends ManagedServiceIdentityClientContext { /** * Initializes a new instance of the ManagedServiceIdentityClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The Id of the Subscription to which the identity belongs. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ManagedServiceIdentityClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ManagedServiceIdentityClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.userAssignedIdentities = new operations.UserAssignedIdentities(this); diff --git a/sdk/msi/arm-msi/src/managedServiceIdentityClientContext.ts b/sdk/msi/arm-msi/src/managedServiceIdentityClientContext.ts index f96cd5df3f4a..884230d49329 100644 --- a/sdk/msi/arm-msi/src/managedServiceIdentityClientContext.ts +++ b/sdk/msi/arm-msi/src/managedServiceIdentityClientContext.ts @@ -10,23 +10,29 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-msi"; -const packageVersion = "0.1.0"; +const packageVersion = "1.2.0"; export class ManagedServiceIdentityClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the ManagedServiceIdentityClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The Id of the Subscription to which the identity belongs. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ManagedServiceIdentityClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ManagedServiceIdentityClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/mysql/arm-mysql/README.md b/sdk/mysql/arm-mysql/README.md index 9c51be4833fe..a2ef706bd607 100644 --- a/sdk/mysql/arm-mysql/README.md +++ b/sdk/mysql/arm-mysql/README.md @@ -1,93 +1,103 @@ ## Azure MySQLManagementClient SDK for JavaScript -This package contains an isomorphic SDK for MySQLManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for MySQLManagementClient. ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge, and Firefox. -### How to Install +### Prerequisites +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/arm-mysql` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/arm-mysql +npm install --save @azure/arm-mysql @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and get servers as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -```bash -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and get servers as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { MySQLManagementClient, MySQLManagementModels, MySQLManagementMappers } from "@azure/arm-mysql"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { MySQLManagementClient } = require("@azure/arm-mysql"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new MySQLManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const serverName = "testserverName"; - client.servers.get(resourceGroupName, serverName).then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new MySQLManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const serverName = "testserverName"; +client.servers.get(resourceGroupName, serverName).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and get servers as an example written in JavaScript. +#### browser - Authentication, client creation, and get servers as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-mysql sample - - + @@ -99,4 +109,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fmysql%2Farm-mysql%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/mysql/arm-mysql/README.png) diff --git a/sdk/mysql/arm-mysql/package.json b/sdk/mysql/arm-mysql/package.json index 002baef71cd0..7a74704f28d7 100644 --- a/sdk/mysql/arm-mysql/package.json +++ b/sdk/mysql/arm-mysql/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-mysql", "author": "Microsoft Corporation", "description": "MySQLManagementClient Library with typescript type definitions for node.js and browser.", - "version": "3.3.0", + "version": "3.4.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.3.2", - "@azure/ms-rest-js": "^1.8.1", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/mySQLManagementClient.js", "types": "./esm/mySQLManagementClient.d.ts", "devDependencies": { - "typescript": "^3.1.1", + "typescript": "^3.6.0", "rollup": "^0.66.2", "rollup-plugin-node-resolve": "^3.4.0", "rollup-plugin-sourcemaps": "^0.4.2", diff --git a/sdk/mysql/arm-mysql/src/mySQLManagementClient.ts b/sdk/mysql/arm-mysql/src/mySQLManagementClient.ts index aa67d2e2852d..f128cfad2096 100644 --- a/sdk/mysql/arm-mysql/src/mySQLManagementClient.ts +++ b/sdk/mysql/arm-mysql/src/mySQLManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -31,11 +32,16 @@ class MySQLManagementClient extends MySQLManagementClientContext { /** * Initializes a new instance of the MySQLManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription ID that identifies an Azure subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.MySQLManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.MySQLManagementClientOptions) { super(credentials, subscriptionId, options); this.servers = new operations.Servers(this); this.replicas = new operations.Replicas(this); diff --git a/sdk/mysql/arm-mysql/src/mySQLManagementClientContext.ts b/sdk/mysql/arm-mysql/src/mySQLManagementClientContext.ts index 7171fdfd9303..91c35fd07caf 100644 --- a/sdk/mysql/arm-mysql/src/mySQLManagementClientContext.ts +++ b/sdk/mysql/arm-mysql/src/mySQLManagementClientContext.ts @@ -10,23 +10,29 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-mysql"; -const packageVersion = "3.3.0"; +const packageVersion = "3.4.0"; export class MySQLManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the MySQLManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription ID that identifies an Azure subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.MySQLManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.MySQLManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/network/arm-network-profile-2019-03-01-hybrid/README.md b/sdk/network/arm-network-profile-2019-03-01-hybrid/README.md index 076cfd4d120d..492ae995e13c 100644 --- a/sdk/network/arm-network-profile-2019-03-01-hybrid/README.md +++ b/sdk/network/arm-network-profile-2019-03-01-hybrid/README.md @@ -1,95 +1,105 @@ ## Azure NetworkManagementClient SDK for JavaScript -This package contains an isomorphic SDK for NetworkManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for NetworkManagementClient. ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge, and Firefox. -### How to Install +### Prerequisites +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/arm-network-profile-2019-03-01-hybrid` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/arm-network-profile-2019-03-01-hybrid +npm install --save @azure/arm-network-profile-2019-03-01-hybrid @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and get loadBalancers as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -```bash -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and get loadBalancers as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { NetworkManagementClient, NetworkManagementModels, NetworkManagementMappers } from "@azure/arm-network-profile-2019-03-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { NetworkManagementClient } = require("@azure/arm-network-profile-2019-03-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new NetworkManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const loadBalancerName = "testloadBalancerName"; - const expand = "testexpand"; - client.loadBalancers.get(resourceGroupName, loadBalancerName, expand).then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new NetworkManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const loadBalancerName = "testloadBalancerName"; +const expand = "testexpand"; +client.loadBalancers.get(resourceGroupName, loadBalancerName, expand).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and get loadBalancers as an example written in JavaScript. +#### browser - Authentication, client creation, and get loadBalancers as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-network-profile-2019-03-01-hybrid sample - - + @@ -101,5 +111,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fnetwork%2Farm-network-profile-2019-03-01-hybrid%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/network/arm-network-profile-2019-03-01-hybrid/README.png) diff --git a/sdk/network/arm-network-profile-2019-03-01-hybrid/package.json b/sdk/network/arm-network-profile-2019-03-01-hybrid/package.json index f3f77e93ae7d..d0ad619a9739 100644 --- a/sdk/network/arm-network-profile-2019-03-01-hybrid/package.json +++ b/sdk/network/arm-network-profile-2019-03-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-network-profile-2019-03-01-hybrid", "author": "Microsoft Corporation", "description": "NetworkManagementClient Library with typescript type definitions for node.js and browser.", - "version": "1.0.0", + "version": "1.1.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.3.2", - "@azure/ms-rest-js": "^1.8.1", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -21,7 +22,7 @@ "module": "./esm/networkManagementClient.js", "types": "./esm/networkManagementClient.d.ts", "devDependencies": { - "typescript": "^3.1.1", + "typescript": "^3.6.0", "rollup": "^0.66.2", "rollup-plugin-node-resolve": "^3.4.0", "rollup-plugin-sourcemaps": "^0.4.2", diff --git a/sdk/network/arm-network-profile-2019-03-01-hybrid/src/networkManagementClient.ts b/sdk/network/arm-network-profile-2019-03-01-hybrid/src/networkManagementClient.ts index f9e40168c7d6..4368d1129f55 100644 --- a/sdk/network/arm-network-profile-2019-03-01-hybrid/src/networkManagementClient.ts +++ b/sdk/network/arm-network-profile-2019-03-01-hybrid/src/networkManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -43,12 +44,17 @@ class NetworkManagementClient extends NetworkManagementClientContext { /** * Initializes a new instance of the NetworkManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription credentials which uniquely identify the Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.NetworkManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.NetworkManagementClientOptions) { super(credentials, subscriptionId, options); this.loadBalancers = new operations.LoadBalancers(this); this.loadBalancerBackendAddressPools = new operations.LoadBalancerBackendAddressPools(this); diff --git a/sdk/network/arm-network-profile-2019-03-01-hybrid/src/networkManagementClientContext.ts b/sdk/network/arm-network-profile-2019-03-01-hybrid/src/networkManagementClientContext.ts index ce45aa70b761..40f0985559df 100644 --- a/sdk/network/arm-network-profile-2019-03-01-hybrid/src/networkManagementClientContext.ts +++ b/sdk/network/arm-network-profile-2019-03-01-hybrid/src/networkManagementClientContext.ts @@ -10,24 +10,30 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-network-profile-2019-03-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class NetworkManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the NetworkManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription credentials which uniquely identify the Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.NetworkManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.NetworkManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/README.md b/sdk/network/arm-network-profile-2020-09-01-hybrid/README.md index 046cb52643b3..e4edc45dbfff 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/README.md +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/README.md @@ -1,94 +1,103 @@ ## Azure NetworkManagementClient SDK for JavaScript -This package contains an isomorphic SDK for NetworkManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for NetworkManagementClient. ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge, and Firefox. -### How to Install +### Prerequisites +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/arm-network-profile-2020-09-01-hybrid` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/arm-network-profile-2020-09-01-hybrid +npm install --save @azure/arm-network-profile-2020-09-01-hybrid @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and get virtualNetworkGateways as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and get virtualNetworkGateways as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { NetworkManagementClient, NetworkManagementModels, NetworkManagementMappers } from "@azure/arm-network-profile-2020-09-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new NetworkManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const virtualNetworkGatewayName = "testvirtualNetworkGatewayName"; - client.virtualNetworkGateways.get(resourceGroupName, virtualNetworkGatewayName).then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new NetworkManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const virtualNetworkGatewayName = "testvirtualNetworkGatewayName"; +client.virtualNetworkGateways.get(resourceGroupName, virtualNetworkGatewayName).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and get virtualNetworkGateways as an example written in JavaScript. +#### browser - Authentication, client creation, and get virtualNetworkGateways as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-network-profile-2020-09-01-hybrid sample - - + diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/package.json b/sdk/network/arm-network-profile-2020-09-01-hybrid/package.json index ed79a4aceedc..c0005d66c673 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/package.json +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-network-profile-2020-09-01-hybrid", "author": "Microsoft Corporation", "description": "NetworkManagementClient Library with typescript type definitions for node.js and browser.", - "version": "1.0.0", + "version": "1.1.0", "dependencies": { - "@azure/ms-rest-azure-js": "^2.0.1", - "@azure/ms-rest-js": "^2.0.4", + "@azure/ms-rest-azure-js": "^2.1.0", + "@azure/ms-rest-js": "^2.2.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.10.0" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/networkManagementClient.js", "types": "./esm/networkManagementClient.d.ts", "devDependencies": { - "typescript": "^3.5.3", + "typescript": "^3.6.0", "rollup": "^1.18.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-sourcemaps": "^0.4.2", diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/networkManagementClient.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/networkManagementClient.ts index fb64d2a973d9..22f2be411cc0 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/networkManagementClient.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/networkManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -45,12 +46,17 @@ class NetworkManagementClient extends NetworkManagementClientContext { /** * Initializes a new instance of the NetworkManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription credentials which uniquely identify the Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.NetworkManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.NetworkManagementClientOptions) { super(credentials, subscriptionId, options); this.virtualNetworkGateways = new operations.VirtualNetworkGateways(this); this.virtualNetworkGatewayConnections = new operations.VirtualNetworkGatewayConnections(this); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/networkManagementClientContext.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/networkManagementClientContext.ts index f5b91c0455e5..01aecafce1fa 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/networkManagementClientContext.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/networkManagementClientContext.ts @@ -10,24 +10,30 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-network-profile-2020-09-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class NetworkManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the NetworkManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription credentials which uniquely identify the Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.NetworkManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.NetworkManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/notificationhubs/arm-notificationhubs/README.md b/sdk/notificationhubs/arm-notificationhubs/README.md index a532f90ee1d2..40aee75f4c3f 100644 --- a/sdk/notificationhubs/arm-notificationhubs/README.md +++ b/sdk/notificationhubs/arm-notificationhubs/README.md @@ -1,89 +1,100 @@ ## Azure NotificationHubsManagementClient SDK for JavaScript -This package contains an isomorphic SDK for NotificationHubsManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for NotificationHubsManagementClient. ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge, and Firefox. -### How to Install +### Prerequisites -``` -npm install @azure/arm-notificationhubs +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/arm-notificationhubs` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: +```bash +npm install --save @azure/arm-notificationhubs @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -``` -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```ts -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { NotificationHubsManagementClient, NotificationHubsManagementModels, NotificationHubsManagementMappers } from "@azure/arm-notificationhubs"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { NotificationHubsManagementClient } = require("@azure/arm-notificationhubs"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new NotificationHubsManagementClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new NotificationHubsManagementClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -``` -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-notificationhubs sample - - + @@ -95,5 +106,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fnotificationhubs%2Farm-notificationhubs%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/notificationhubs/arm-notificationhubs/README.png) diff --git a/sdk/notificationhubs/arm-notificationhubs/package.json b/sdk/notificationhubs/arm-notificationhubs/package.json index 0f31c8842534..ee33b14f8407 100644 --- a/sdk/notificationhubs/arm-notificationhubs/package.json +++ b/sdk/notificationhubs/arm-notificationhubs/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-notificationhubs", "author": "Microsoft Corporation", "description": "NotificationHubsManagementClient Library with typescript type definitions for node.js and browser.", - "version": "1.2.0", + "version": "1.3.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.1.0", - "@azure/ms-rest-js": "^1.1.0", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/notificationHubsManagementClient.js", "types": "./esm/notificationHubsManagementClient.d.ts", "devDependencies": { - "typescript": "^3.1.1", + "typescript": "^3.6.0", "rollup": "^0.66.2", "rollup-plugin-node-resolve": "^3.4.0", "uglify-js": "^3.4.9" diff --git a/sdk/notificationhubs/arm-notificationhubs/src/notificationHubsManagementClient.ts b/sdk/notificationhubs/arm-notificationhubs/src/notificationHubsManagementClient.ts index 75528c3e49ed..fe54974b5635 100644 --- a/sdk/notificationhubs/arm-notificationhubs/src/notificationHubsManagementClient.ts +++ b/sdk/notificationhubs/arm-notificationhubs/src/notificationHubsManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -23,12 +24,17 @@ class NotificationHubsManagementClient extends NotificationHubsManagementClientC /** * Initializes a new instance of the NotificationHubsManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Gets subscription credentials which uniquely identify Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.NotificationHubsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.NotificationHubsManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.namespaces = new operations.Namespaces(this); diff --git a/sdk/notificationhubs/arm-notificationhubs/src/notificationHubsManagementClientContext.ts b/sdk/notificationhubs/arm-notificationhubs/src/notificationHubsManagementClientContext.ts index 3b6d5b8e08bf..6f05e39cb6bd 100644 --- a/sdk/notificationhubs/arm-notificationhubs/src/notificationHubsManagementClientContext.ts +++ b/sdk/notificationhubs/arm-notificationhubs/src/notificationHubsManagementClientContext.ts @@ -10,24 +10,30 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-notificationhubs"; -const packageVersion = "0.1.0"; +const packageVersion = "1.3.0"; export class NotificationHubsManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the NotificationHubsManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Gets subscription credentials which uniquely identify Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.NotificationHubsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.NotificationHubsManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/operationalinsights/arm-operationalinsights/README.md b/sdk/operationalinsights/arm-operationalinsights/README.md index bf3a79c85aea..513d0855bfb6 100644 --- a/sdk/operationalinsights/arm-operationalinsights/README.md +++ b/sdk/operationalinsights/arm-operationalinsights/README.md @@ -1,93 +1,103 @@ ## Azure OperationalInsightsManagementClient SDK for JavaScript -This package contains an isomorphic SDK for OperationalInsightsManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for OperationalInsightsManagementClient. ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge, and Firefox. -### How to Install +### Prerequisites +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/arm-operationalinsights` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/arm-operationalinsights +npm install --save @azure/arm-operationalinsights @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - client creation and listByWorkspace dataExports as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and listByWorkspace dataExports as an example written in JavaScript. ##### Sample code -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 -```typescript -const msRestNodeAuth = require("@azure/ms-rest-nodeauth"); +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); const { OperationalInsightsManagementClient } = require("@azure/arm-operationalinsights"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new OperationalInsightsManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const workspaceName = "testworkspaceName"; - client.dataExports.listByWorkspace(resourceGroupName, workspaceName).then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new OperationalInsightsManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const workspaceName = "testworkspaceName"; +client.dataExports.listByWorkspace(resourceGroupName, workspaceName).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and listByWorkspace dataExports as an example written in JavaScript. +#### browser - Authentication, client creation, and listByWorkspace dataExports as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-operationalinsights sample - - + diff --git a/sdk/operationalinsights/arm-operationalinsights/package.json b/sdk/operationalinsights/arm-operationalinsights/package.json index c1c039dcd080..89e2cd8ef7dc 100644 --- a/sdk/operationalinsights/arm-operationalinsights/package.json +++ b/sdk/operationalinsights/arm-operationalinsights/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-operationalinsights", "author": "Microsoft Corporation", "description": "OperationalInsightsManagementClient Library with typescript type definitions for node.js and browser.", - "version": "7.0.0", + "version": "7.1.0", "dependencies": { - "@azure/ms-rest-azure-js": "^2.0.1", - "@azure/ms-rest-js": "^2.0.4", + "@azure/ms-rest-azure-js": "^2.1.0", + "@azure/ms-rest-js": "^2.2.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.10.0" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/operationalInsightsManagementClient.js", "types": "./esm/operationalInsightsManagementClient.d.ts", "devDependencies": { - "typescript": "^3.5.3", + "typescript": "^3.6.0", "rollup": "^1.18.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-sourcemaps": "^0.4.2", diff --git a/sdk/operationalinsights/arm-operationalinsights/src/operationalInsightsManagementClient.ts b/sdk/operationalinsights/arm-operationalinsights/src/operationalInsightsManagementClient.ts index 0d6ac9045e4e..525b04c140bc 100644 --- a/sdk/operationalinsights/arm-operationalinsights/src/operationalInsightsManagementClient.ts +++ b/sdk/operationalinsights/arm-operationalinsights/src/operationalInsightsManagementClient.ts @@ -8,6 +8,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -39,11 +40,16 @@ class OperationalInsightsManagementClient extends OperationalInsightsManagementC /** * Initializes a new instance of the OperationalInsightsManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The ID of the target subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.OperationalInsightsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.OperationalInsightsManagementClientOptions) { super(credentials, subscriptionId, options); this.dataExports = new operations.DataExports(this); this.dataSources = new operations.DataSources(this); diff --git a/sdk/operationalinsights/arm-operationalinsights/src/operationalInsightsManagementClientContext.ts b/sdk/operationalinsights/arm-operationalinsights/src/operationalInsightsManagementClientContext.ts index fda0af09728d..1f39e7a95ac0 100644 --- a/sdk/operationalinsights/arm-operationalinsights/src/operationalInsightsManagementClientContext.ts +++ b/sdk/operationalinsights/arm-operationalinsights/src/operationalInsightsManagementClientContext.ts @@ -9,23 +9,29 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-operationalinsights"; -const packageVersion = "7.0.0"; +const packageVersion = "7.1.0"; export class OperationalInsightsManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the OperationalInsightsManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The ID of the target subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.OperationalInsightsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.OperationalInsightsManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/operationsmanagement/arm-operations/README.md b/sdk/operationsmanagement/arm-operations/README.md index b2c9efb3eecc..43f7f84ffe30 100644 --- a/sdk/operationsmanagement/arm-operations/README.md +++ b/sdk/operationsmanagement/arm-operations/README.md @@ -1,93 +1,103 @@ ## Azure OperationsManagementClient SDK for JavaScript -This package contains an isomorphic SDK for OperationsManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for OperationsManagementClient. ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge, and Firefox. -### How to Install +### Prerequisites -``` -npm install @azure/arm-operations +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/arm-operations` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: +```bash +npm install --save @azure/arm-operations @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and get solutions as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -``` -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and get solutions as an example written in JavaScript. ##### Sample code -```ts -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { OperationsManagementClient, OperationsManagementModels, OperationsManagementMappers } from "@azure/arm-operations"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { OperationsManagementClient } = require("@azure/arm-operations"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new OperationsManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const solutionName = "testsolutionName"; - client.solutions.get(resourceGroupName, solutionName).then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new OperationsManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const solutionName = "testsolutionName"; +client.solutions.get(resourceGroupName, solutionName).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and get solutions as an example written in JavaScript. +#### browser - Authentication, client creation, and get solutions as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -``` -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-operations sample - - + @@ -99,5 +109,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Foperationsmanagement%2Farm-operations%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/operationsmanagement/arm-operations/README.png) diff --git a/sdk/operationsmanagement/arm-operations/package.json b/sdk/operationsmanagement/arm-operations/package.json index 56e114a52dd6..b26129943ce8 100644 --- a/sdk/operationsmanagement/arm-operations/package.json +++ b/sdk/operationsmanagement/arm-operations/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-operations", "author": "Microsoft Corporation", "description": "OperationsManagementClient Library with typescript type definitions for node.js and browser.", - "version": "2.1.0", + "version": "2.2.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.1.0", - "@azure/ms-rest-js": "^1.1.0", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/operationsManagementClient.js", "types": "./esm/operationsManagementClient.d.ts", "devDependencies": { - "typescript": "^3.1.1", + "typescript": "^3.6.0", "rollup": "^0.66.2", "rollup-plugin-node-resolve": "^3.4.0", "uglify-js": "^3.4.9" diff --git a/sdk/operationsmanagement/arm-operations/src/operationsManagementClient.ts b/sdk/operationsmanagement/arm-operations/src/operationsManagementClient.ts index cc22a452f329..9097e6a74ebb 100644 --- a/sdk/operationsmanagement/arm-operations/src/operationsManagementClient.ts +++ b/sdk/operationsmanagement/arm-operations/src/operationsManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -24,7 +25,12 @@ class OperationsManagementClient extends OperationsManagementClientContext { /** * Initializes a new instance of the OperationsManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Gets subscription credentials which uniquely identify Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param providerName Provider name for the parent resource. @@ -32,7 +38,7 @@ class OperationsManagementClient extends OperationsManagementClientContext { * @param resourceName Parent resource name. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, providerName: string, resourceType: string, resourceName: string, options?: Models.OperationsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, providerName: string, resourceType: string, resourceName: string, options?: Models.OperationsManagementClientOptions) { super(credentials, subscriptionId, providerName, resourceType, resourceName, options); this.solutions = new operations.Solutions(this); this.managementAssociations = new operations.ManagementAssociations(this); diff --git a/sdk/operationsmanagement/arm-operations/src/operationsManagementClientContext.ts b/sdk/operationsmanagement/arm-operations/src/operationsManagementClientContext.ts index 9902f9b551f6..54f7c62ac6d4 100644 --- a/sdk/operationsmanagement/arm-operations/src/operationsManagementClientContext.ts +++ b/sdk/operationsmanagement/arm-operations/src/operationsManagementClientContext.ts @@ -10,13 +10,14 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-operations"; -const packageVersion = "0.1.0"; +const packageVersion = "2.2.0"; export class OperationsManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; providerName: string; @@ -25,7 +26,12 @@ export class OperationsManagementClientContext extends msRestAzure.AzureServiceC /** * Initializes a new instance of the OperationsManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Gets subscription credentials which uniquely identify Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param providerName Provider name for the parent resource. @@ -33,7 +39,7 @@ export class OperationsManagementClientContext extends msRestAzure.AzureServiceC * @param resourceName Parent resource name. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, providerName: string, resourceType: string, resourceName: string, options?: Models.OperationsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, providerName: string, resourceType: string, resourceName: string, options?: Models.OperationsManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); }