diff --git a/sdk/recoveryservices/arm-recoveryservices/README.md b/sdk/recoveryservices/arm-recoveryservices/README.md index 54336c35cd94..ab315519a42c 100644 --- a/sdk/recoveryservices/arm-recoveryservices/README.md +++ b/sdk/recoveryservices/arm-recoveryservices/README.md @@ -1,93 +1,103 @@ ## Azure RecoveryServicesClient SDK for JavaScript -This package contains an isomorphic SDK for RecoveryServicesClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for RecoveryServicesClient. ### 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-recoveryservices` 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-recoveryservices +npm install --save @azure/arm-recoveryservices @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 list replicationUsages 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 replicationUsages 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 { RecoveryServicesClient } = require("@azure/arm-recoveryservices"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new RecoveryServicesClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const vaultName = "testvaultName"; - client.replicationUsages.list(resourceGroupName, vaultName).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 RecoveryServicesClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const vaultName = "testvaultName"; +client.replicationUsages.list(resourceGroupName, vaultName).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 replicationUsages as an example written in JavaScript. +#### browser - Authentication, client creation, and list replicationUsages 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-recoveryservices sample - - + diff --git a/sdk/recoveryservices/arm-recoveryservices/package.json b/sdk/recoveryservices/arm-recoveryservices/package.json index 20376606d69b..1ecba9962174 100644 --- a/sdk/recoveryservices/arm-recoveryservices/package.json +++ b/sdk/recoveryservices/arm-recoveryservices/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-recoveryservices", "author": "Microsoft Corporation", "description": "RecoveryServicesClient Library with typescript type definitions for node.js and browser.", - "version": "4.1.0", + "version": "4.2.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/recoveryServicesClient.js", "types": "./esm/recoveryServicesClient.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/recoveryservices/arm-recoveryservices/src/recoveryServicesClient.ts b/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClient.ts index 7e1df780c2ed..d15c270d9e32 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClient.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClient.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"; @@ -28,11 +29,16 @@ class RecoveryServicesClient extends RecoveryServicesClientContext { /** * Initializes a new instance of the RecoveryServicesClient 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. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.RecoveryServicesClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.RecoveryServicesClientOptions) { super(credentials, subscriptionId, options); this.vaultCertificates = new operations.VaultCertificates(this); this.registeredIdentities = new operations.RegisteredIdentities(this); diff --git a/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClientContext.ts b/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClientContext.ts index 01afef1bd386..9d0b92a7d8d7 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClientContext.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClientContext.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-recoveryservices"; -const packageVersion = "4.1.0"; +const packageVersion = "4.2.0"; export class RecoveryServicesClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the RecoveryServicesClient 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. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.RecoveryServicesClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.RecoveryServicesClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/serialconsole/arm-serialconsole/README.md b/sdk/serialconsole/arm-serialconsole/README.md index 8fcae878eebe..f82477f8a106 100644 --- a/sdk/serialconsole/arm-serialconsole/README.md +++ b/sdk/serialconsole/arm-serialconsole/README.md @@ -1,89 +1,100 @@ ## Azure MicrosoftSerialConsoleClient SDK for JavaScript -This package contains an isomorphic SDK for MicrosoftSerialConsoleClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for MicrosoftSerialConsoleClient. ### 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-serialconsole` 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-serialconsole +npm install --save @azure/arm-serialconsole @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 operations list 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 operations list 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 { MicrosoftSerialConsoleClient, MicrosoftSerialConsoleModels, MicrosoftSerialConsoleMappers } from "@azure/arm-serialconsole"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { MicrosoftSerialConsoleClient } = require("@azure/arm-serialconsole"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new MicrosoftSerialConsoleClient(creds, subscriptionId); - client.list.operations().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 MicrosoftSerialConsoleClient(creds, subscriptionId); + +client.list.operations().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 operations list as an example written in JavaScript. +#### browser - Authentication, client creation, and operations list 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-serialconsole 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%2Fserialconsole%2Farm-serialconsole%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/serialconsole/arm-serialconsole/README.png) diff --git a/sdk/serialconsole/arm-serialconsole/package.json b/sdk/serialconsole/arm-serialconsole/package.json index f2093c23c83a..45a0b393d480 100644 --- a/sdk/serialconsole/arm-serialconsole/package.json +++ b/sdk/serialconsole/arm-serialconsole/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-serialconsole", "author": "Microsoft Corporation", "description": "MicrosoftSerialConsoleClient 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": [ @@ -20,7 +21,7 @@ "module": "./esm/microsoftSerialConsoleClient.js", "types": "./esm/microsoftSerialConsoleClient.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/serialconsole/arm-serialconsole/src/microsoftSerialConsoleClient.ts b/sdk/serialconsole/arm-serialconsole/src/microsoftSerialConsoleClient.ts index ba521794b237..9735e35a8420 100644 --- a/sdk/serialconsole/arm-serialconsole/src/microsoftSerialConsoleClient.ts +++ b/sdk/serialconsole/arm-serialconsole/src/microsoftSerialConsoleClient.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,11 +24,16 @@ class MicrosoftSerialConsoleClient extends MicrosoftSerialConsoleClientContext { /** * Initializes a new instance of the MicrosoftSerialConsoleClient 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.MicrosoftSerialConsoleClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.MicrosoftSerialConsoleClientOptions) { super(credentials, subscriptionId, options); this.list = new operations.List(this); this.listConsole = new operations.ListConsole(this); diff --git a/sdk/serialconsole/arm-serialconsole/src/microsoftSerialConsoleClientContext.ts b/sdk/serialconsole/arm-serialconsole/src/microsoftSerialConsoleClientContext.ts index 1478ee9b10b3..2fda18a50afb 100644 --- a/sdk/serialconsole/arm-serialconsole/src/microsoftSerialConsoleClientContext.ts +++ b/sdk/serialconsole/arm-serialconsole/src/microsoftSerialConsoleClientContext.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-serialconsole"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class MicrosoftSerialConsoleClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the MicrosoftSerialConsoleClient 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.MicrosoftSerialConsoleClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.MicrosoftSerialConsoleClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/service-map/arm-servicemap/README.md b/sdk/service-map/arm-servicemap/README.md index fc63791a3f0a..68f74734fbc0 100644 --- a/sdk/service-map/arm-servicemap/README.md +++ b/sdk/service-map/arm-servicemap/README.md @@ -1,103 +1,113 @@ ## Azure ServicemapManagementClient SDK for JavaScript -This package contains an isomorphic SDK for ServicemapManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ServicemapManagementClient. ### 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-servicemap` 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-servicemap +npm install --save @azure/arm-servicemap @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 listByWorkspace machines 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 listByWorkspace machines 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 { ServicemapManagementClient, ServicemapManagementModels, ServicemapManagementMappers } from "@azure/arm-servicemap"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { ServicemapManagementClient } = require("@azure/arm-servicemap"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ServicemapManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const workspaceName = "testworkspaceName"; - const live = true; - const startTime = new Date().toISOString(); - const endTime = new Date().toISOString(); - const timestamp = new Date().toISOString(); - const top = 1; - client.machines.listByWorkspace(resourceGroupName, workspaceName, live, startTime, endTime, timestamp, top).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 ServicemapManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const workspaceName = "testworkspaceName"; +const live = true; +const startTime = new Date().toISOString(); +const endTime = new Date().toISOString(); +const timestamp = new Date().toISOString(); +const top = 1; +client.machines.listByWorkspace(resourceGroupName, workspaceName, live, startTime, endTime, timestamp, top).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 machines as an example written in JavaScript. +#### browser - Authentication, client creation, and listByWorkspace machines 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-servicemap sample - - + @@ -109,4 +119,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%2Fservice-map%2Farm-servicemap%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/service-map/arm-servicemap/README.png) diff --git a/sdk/service-map/arm-servicemap/package.json b/sdk/service-map/arm-servicemap/package.json index 0fd1d7250ed8..cfa445d99063 100644 --- a/sdk/service-map/arm-servicemap/package.json +++ b/sdk/service-map/arm-servicemap/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-servicemap", "author": "Microsoft Corporation", "description": "ServicemapManagementClient Library with typescript type definitions for node.js and browser.", - "version": "2.2.0", + "version": "2.3.0", "dependencies": { - "@azure/ms-rest-azure-js": "^2.0.0", - "@azure/ms-rest-js": "^2.0.3", + "@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/servicemapManagementClient.js", "types": "./esm/servicemapManagementClient.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/service-map/arm-servicemap/src/servicemapManagementClient.ts b/sdk/service-map/arm-servicemap/src/servicemapManagementClient.ts index 22ab164d4ac2..a8725b5b9c85 100644 --- a/sdk/service-map/arm-servicemap/src/servicemapManagementClient.ts +++ b/sdk/service-map/arm-servicemap/src/servicemapManagementClient.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"; @@ -27,11 +28,16 @@ class ServicemapManagementClient extends ServicemapManagementClientContext { /** * Initializes a new instance of the ServicemapManagementClient 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 Azure subscription identifier. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ServicemapManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ServicemapManagementClientOptions) { super(credentials, subscriptionId, options); this.machines = new operations.Machines(this); this.processes = new operations.Processes(this); diff --git a/sdk/service-map/arm-servicemap/src/servicemapManagementClientContext.ts b/sdk/service-map/arm-servicemap/src/servicemapManagementClientContext.ts index 782f18140578..ccdb98cfe729 100644 --- a/sdk/service-map/arm-servicemap/src/servicemapManagementClientContext.ts +++ b/sdk/service-map/arm-servicemap/src/servicemapManagementClientContext.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-servicemap"; -const packageVersion = "2.2.0"; +const packageVersion = "2.3.0"; export class ServicemapManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the ServicemapManagementClient 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 Azure subscription identifier. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ServicemapManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ServicemapManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/servicebus/arm-servicebus/README.md b/sdk/servicebus/arm-servicebus/README.md index b14c18cc53b8..81020e0cfe26 100644 --- a/sdk/servicebus/arm-servicebus/README.md +++ b/sdk/servicebus/arm-servicebus/README.md @@ -1,90 +1,100 @@ ## Azure ServiceBusManagementClient SDK for JavaScript -This package contains an isomorphic SDK for ServiceBusManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ServiceBusManagementClient. ### 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-servicebus` 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-servicebus +npm install --save @azure/arm-servicebus @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. -- 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 operations 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 { ServiceBusManagementClient, ServiceBusManagementModels, ServiceBusManagementMappers } from "@azure/arm-servicebus"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { ServiceBusManagementClient } = require("@azure/arm-servicebus"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ServiceBusManagementClient(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 ServiceBusManagementClient(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. -```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-servicebus sample - - + diff --git a/sdk/servicebus/arm-servicebus/package.json b/sdk/servicebus/arm-servicebus/package.json index 4a3e56681e22..fe7310bb84d2 100644 --- a/sdk/servicebus/arm-servicebus/package.json +++ b/sdk/servicebus/arm-servicebus/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-servicebus", "author": "Microsoft Corporation", "description": "ServiceBusManagementClient Library with typescript type definitions for node.js and browser.", - "version": "4.0.0", + "version": "4.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/serviceBusManagementClient.js", "types": "./esm/serviceBusManagementClient.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/servicebus/arm-servicebus/src/serviceBusManagementClient.ts b/sdk/servicebus/arm-servicebus/src/serviceBusManagementClient.ts index d2cb78a62bf5..f289ed461edd 100644 --- a/sdk/servicebus/arm-servicebus/src/serviceBusManagementClient.ts +++ b/sdk/servicebus/arm-servicebus/src/serviceBusManagementClient.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,12 +32,17 @@ class ServiceBusManagementClient extends ServiceBusManagementClientContext { /** * Initializes a new instance of the ServiceBusManagementClient 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 Subscription credentials that uniquely identify a 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.ServiceBusManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ServiceBusManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.namespaces = new operations.Namespaces(this); diff --git a/sdk/servicebus/arm-servicebus/src/serviceBusManagementClientContext.ts b/sdk/servicebus/arm-servicebus/src/serviceBusManagementClientContext.ts index 49a30c3cba92..44ffe2155450 100644 --- a/sdk/servicebus/arm-servicebus/src/serviceBusManagementClientContext.ts +++ b/sdk/servicebus/arm-servicebus/src/serviceBusManagementClientContext.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-servicebus"; -const packageVersion = "4.0.0"; +const packageVersion = "4.1.0"; export class ServiceBusManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the ServiceBusManagementClient 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 Subscription credentials that uniquely identify a 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.ServiceBusManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ServiceBusManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/servicefabric/arm-servicefabric/README.md b/sdk/servicefabric/arm-servicefabric/README.md index 04ec2c7d4bd6..37a16ad25db6 100644 --- a/sdk/servicefabric/arm-servicefabric/README.md +++ b/sdk/servicefabric/arm-servicefabric/README.md @@ -1,94 +1,103 @@ ## Azure ServiceFabricManagementClient SDK for JavaScript -This package contains an isomorphic SDK for ServiceFabricManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ServiceFabricManagementClient. ### 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-servicefabric` 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-servicefabric +npm install --save @azure/arm-servicefabric @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 clusters 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 clusters 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 { ServiceFabricManagementClient, ServiceFabricManagementModels, ServiceFabricManagementMappers } from "@azure/arm-servicefabric"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { ServiceFabricManagementClient } = require("@azure/arm-servicefabric"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ServiceFabricManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const clusterName = "testclusterName"; - client.clusters.get(resourceGroupName, clusterName).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 ServiceFabricManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const clusterName = "testclusterName"; +client.clusters.get(resourceGroupName, clusterName).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 clusters as an example written in JavaScript. +#### browser - Authentication, client creation, and get clusters 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-servicefabric sample - - + diff --git a/sdk/servicefabric/arm-servicefabric/package.json b/sdk/servicefabric/arm-servicefabric/package.json index 09e9088903be..98a10ebc21f0 100644 --- a/sdk/servicefabric/arm-servicefabric/package.json +++ b/sdk/servicefabric/arm-servicefabric/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-servicefabric", "author": "Microsoft Corporation", "description": "ServiceFabricManagementClient 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/serviceFabricManagementClient.js", "types": "./esm/serviceFabricManagementClient.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/servicefabric/arm-servicefabric/src/serviceFabricManagementClient.ts b/sdk/servicefabric/arm-servicefabric/src/serviceFabricManagementClient.ts index df9866ea3461..8d396cf11af4 100644 --- a/sdk/servicefabric/arm-servicefabric/src/serviceFabricManagementClient.ts +++ b/sdk/servicefabric/arm-servicefabric/src/serviceFabricManagementClient.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"; @@ -30,11 +31,16 @@ class ServiceFabricManagementClient extends ServiceFabricManagementClientContext /** * Initializes a new instance of the ServiceFabricManagementClient 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 customer subscription identifier. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ServiceFabricManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ServiceFabricManagementClientOptions) { super(credentials, subscriptionId, options); this.clusters = new operations.Clusters(this); this.clusterVersions = new operations.ClusterVersions(this); diff --git a/sdk/servicefabric/arm-servicefabric/src/serviceFabricManagementClientContext.ts b/sdk/servicefabric/arm-servicefabric/src/serviceFabricManagementClientContext.ts index b2a44ab3f52f..1b2bd54440af 100644 --- a/sdk/servicefabric/arm-servicefabric/src/serviceFabricManagementClientContext.ts +++ b/sdk/servicefabric/arm-servicefabric/src/serviceFabricManagementClientContext.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-servicefabric"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class ServiceFabricManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; /** * Initializes a new instance of the ServiceFabricManagementClient 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 customer subscription identifier. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ServiceFabricManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ServiceFabricManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/servicefabricmesh/arm-servicefabricmesh/README.md b/sdk/servicefabricmesh/arm-servicefabricmesh/README.md index 8201d8575194..d1f3156643dd 100644 --- a/sdk/servicefabricmesh/arm-servicefabricmesh/README.md +++ b/sdk/servicefabricmesh/arm-servicefabricmesh/README.md @@ -1,89 +1,100 @@ ## Azure ServiceFabricMeshManagementClient SDK for JavaScript -This package contains an isomorphic SDK for ServiceFabricMeshManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ServiceFabricMeshManagementClient. ### 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-servicefabricmesh +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-servicefabricmesh` 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-servicefabricmesh @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 { ServiceFabricMeshManagementClient, ServiceFabricMeshManagementModels, ServiceFabricMeshManagementMappers } from "@azure/arm-servicefabricmesh"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { ServiceFabricMeshManagementClient } = require("@azure/arm-servicefabricmesh"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ServiceFabricMeshManagementClient(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 ServiceFabricMeshManagementClient(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-servicefabricmesh 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%2Fservicefabricmesh%2Farm-servicefabricmesh%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/servicefabricmesh/arm-servicefabricmesh/README.png) diff --git a/sdk/servicefabricmesh/arm-servicefabricmesh/package.json b/sdk/servicefabricmesh/arm-servicefabricmesh/package.json index fdd1e11017b6..9bc80260c79b 100644 --- a/sdk/servicefabricmesh/arm-servicefabricmesh/package.json +++ b/sdk/servicefabricmesh/arm-servicefabricmesh/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-servicefabricmesh", "author": "Microsoft Corporation", "description": "ServiceFabricMeshManagementClient 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/serviceFabricMeshManagementClient.js", "types": "./esm/serviceFabricMeshManagementClient.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/servicefabricmesh/arm-servicefabricmesh/src/serviceFabricMeshManagementClient.ts b/sdk/servicefabricmesh/arm-servicefabricmesh/src/serviceFabricMeshManagementClient.ts index d63849585195..f8e97eff4825 100644 --- a/sdk/servicefabricmesh/arm-servicefabricmesh/src/serviceFabricMeshManagementClient.ts +++ b/sdk/servicefabricmesh/arm-servicefabricmesh/src/serviceFabricMeshManagementClient.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"; @@ -30,11 +31,16 @@ class ServiceFabricMeshManagementClient extends ServiceFabricMeshManagementClien /** * Initializes a new instance of the ServiceFabricMeshManagementClient 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 customer subscription identifier * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ServiceFabricMeshManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ServiceFabricMeshManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.secret = new operations.Secret(this); diff --git a/sdk/servicefabricmesh/arm-servicefabricmesh/src/serviceFabricMeshManagementClientContext.ts b/sdk/servicefabricmesh/arm-servicefabricmesh/src/serviceFabricMeshManagementClientContext.ts index 2cb5036ab674..b34764aa52c1 100644 --- a/sdk/servicefabricmesh/arm-servicefabricmesh/src/serviceFabricMeshManagementClientContext.ts +++ b/sdk/servicefabricmesh/arm-servicefabricmesh/src/serviceFabricMeshManagementClientContext.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-servicefabricmesh"; -const packageVersion = "0.1.0"; +const packageVersion = "2.2.0"; export class ServiceFabricMeshManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the ServiceFabricMeshManagementClient 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 customer subscription identifier * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ServiceFabricMeshManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ServiceFabricMeshManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/signalr/arm-signalr/README.md b/sdk/signalr/arm-signalr/README.md index 7423938c8103..41b5de8f57fa 100644 --- a/sdk/signalr/arm-signalr/README.md +++ b/sdk/signalr/arm-signalr/README.md @@ -1,65 +1,74 @@ ## Azure SignalRManagementClient SDK for JavaScript -This package contains an isomorphic SDK for SignalRManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for SignalRManagementClient. ### 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-signalr` 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-signalr +npm install --save @azure/arm-signalr @azure/identity ``` -### How to use +> **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. -#### nodejs - client creation and list operations as an example written in TypeScript. +### How to use -##### Install @azure/ms-rest-nodeauth +- 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. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. +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@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list operations 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 { SignalRManagementClient } = require("@azure/arm-signalr"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth - .interactiveLogin() - .then((creds) => { - const client = new SignalRManagementClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); - }) - .catch((err) => { - console.error(err); - }); +// 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 SignalRManagementClient(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. -```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 @@ -67,32 +76,25 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to @azure/arm-signalr sample - - + diff --git a/sdk/signalr/arm-signalr/package.json b/sdk/signalr/arm-signalr/package.json index d6e619813daa..3b83e183076c 100644 --- a/sdk/signalr/arm-signalr/package.json +++ b/sdk/signalr/arm-signalr/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-signalr", "author": "Microsoft Corporation", "description": "SignalRManagementClient Library with typescript type definitions for node.js and browser.", - "version": "4.0.0", + "version": "4.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/signalRManagementClient.js", "types": "./esm/signalRManagementClient.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/signalr/arm-signalr/src/signalRManagementClient.ts b/sdk/signalr/arm-signalr/src/signalRManagementClient.ts index f89ba0585838..8d164ba3d84f 100644 --- a/sdk/signalr/arm-signalr/src/signalRManagementClient.ts +++ b/sdk/signalr/arm-signalr/src/signalRManagementClient.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"; @@ -24,13 +25,18 @@ class SignalRManagementClient extends SignalRManagementClientContext { /** * Initializes a new instance of the SignalRManagementClient 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 Id 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, + credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.SignalRManagementClientOptions ) { diff --git a/sdk/signalr/arm-signalr/src/signalRManagementClientContext.ts b/sdk/signalr/arm-signalr/src/signalRManagementClientContext.ts index 066c749b799a..d087e8bdb6ae 100644 --- a/sdk/signalr/arm-signalr/src/signalRManagementClientContext.ts +++ b/sdk/signalr/arm-signalr/src/signalRManagementClientContext.ts @@ -9,25 +9,31 @@ 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-signalr"; -const packageVersion = "4.0.0"; +const packageVersion = "4.1.0"; export class SignalRManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the SignalRManagementClient 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 Id 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, + credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.SignalRManagementClientOptions ) { diff --git a/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/README.md b/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/README.md index ac5fca0a2f2a..33f39830ef60 100644 --- a/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/README.md +++ b/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/README.md @@ -1,96 +1,105 @@ ## Azure SqlVirtualMachineManagementClient SDK for JavaScript -This package contains an isomorphic SDK for SqlVirtualMachineManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for SqlVirtualMachineManagementClient. ### 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-sqlvirtualmachine` 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-sqlvirtualmachine +npm install --save @azure/arm-sqlvirtualmachine @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 availabilityGroupListeners 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 availabilityGroupListeners 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 { SqlVirtualMachineManagementClient, SqlVirtualMachineManagementModels, SqlVirtualMachineManagementMappers } from "@azure/arm-sqlvirtualmachine"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { SqlVirtualMachineManagementClient } = require("@azure/arm-sqlvirtualmachine"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new SqlVirtualMachineManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const sqlVirtualMachineGroupName = "testsqlVirtualMachineGroupName"; - const availabilityGroupListenerName = "testavailabilityGroupListenerName"; - client.availabilityGroupListeners.get(resourceGroupName, sqlVirtualMachineGroupName, availabilityGroupListenerName).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 SqlVirtualMachineManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const sqlVirtualMachineGroupName = "testsqlVirtualMachineGroupName"; +const availabilityGroupListenerName = "testavailabilityGroupListenerName"; +client.availabilityGroupListeners.get(resourceGroupName, sqlVirtualMachineGroupName, availabilityGroupListenerName).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 availabilityGroupListeners as an example written in JavaScript. +#### browser - Authentication, client creation, and get availabilityGroupListeners 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-sqlvirtualmachine sample - - + diff --git a/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/package.json b/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/package.json index d398e0f6d994..139c5e42f65f 100644 --- a/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/package.json +++ b/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-sqlvirtualmachine", "author": "Microsoft Corporation", "description": "SqlVirtualMachineManagementClient Library with typescript type definitions for node.js and browser.", - "version": "4.0.0", + "version": "4.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/sqlVirtualMachineManagementClient.js", "types": "./esm/sqlVirtualMachineManagementClient.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/sqlvirtualmachine/arm-sqlvirtualmachine/src/sqlVirtualMachineManagementClient.ts b/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/src/sqlVirtualMachineManagementClient.ts index 1e7c8b18f037..8605a2c6a825 100644 --- a/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/src/sqlVirtualMachineManagementClient.ts +++ b/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/src/sqlVirtualMachineManagementClient.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,11 +25,16 @@ class SqlVirtualMachineManagementClient extends SqlVirtualMachineManagementClien /** * Initializes a new instance of the SqlVirtualMachineManagementClient 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 Subscription ID that identifies an Azure subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.SqlVirtualMachineManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.SqlVirtualMachineManagementClientOptions) { super(credentials, subscriptionId, options); this.availabilityGroupListeners = new operations.AvailabilityGroupListeners(this); this.operations = new operations.Operations(this); diff --git a/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/src/sqlVirtualMachineManagementClientContext.ts b/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/src/sqlVirtualMachineManagementClientContext.ts index fd4e2c8469cf..f72063e4112d 100644 --- a/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/src/sqlVirtualMachineManagementClientContext.ts +++ b/sdk/sqlvirtualmachine/arm-sqlvirtualmachine/src/sqlVirtualMachineManagementClientContext.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-sqlvirtualmachine"; -const packageVersion = "4.0.0"; +const packageVersion = "4.1.0"; export class SqlVirtualMachineManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the SqlVirtualMachineManagementClient 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 Subscription ID that identifies an Azure subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.SqlVirtualMachineManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.SqlVirtualMachineManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/storage/arm-storage-profile-2019-03-01-hybrid/README.md b/sdk/storage/arm-storage-profile-2019-03-01-hybrid/README.md index 970386f1d2f2..433fac8b794e 100644 --- a/sdk/storage/arm-storage-profile-2019-03-01-hybrid/README.md +++ b/sdk/storage/arm-storage-profile-2019-03-01-hybrid/README.md @@ -1,89 +1,100 @@ ## Azure StorageManagementClient SDK for JavaScript -This package contains an isomorphic SDK for StorageManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for StorageManagementClient. ### 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-storage-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-storage-profile-2019-03-01-hybrid +npm install --save @azure/arm-storage-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 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. -```bash -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list operations 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 { StorageManagementClient, StorageManagementModels, StorageManagementMappers } from "@azure/arm-storage-profile-2019-03-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { StorageManagementClient } = require("@azure/arm-storage-profile-2019-03-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new StorageManagementClient(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 StorageManagementClient(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. +#### browser - Authentication, client creation, and list operations 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-storage-profile-2019-03-01-hybrid 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%2Fstorage%2Farm-storage-profile-2019-03-01-hybrid%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/storage/arm-storage-profile-2019-03-01-hybrid/README.png) diff --git a/sdk/storage/arm-storage-profile-2019-03-01-hybrid/package.json b/sdk/storage/arm-storage-profile-2019-03-01-hybrid/package.json index 74c912b34582..c731499aa5b8 100644 --- a/sdk/storage/arm-storage-profile-2019-03-01-hybrid/package.json +++ b/sdk/storage/arm-storage-profile-2019-03-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-storage-profile-2019-03-01-hybrid", "author": "Microsoft Corporation", "description": "StorageManagementClient 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/storageManagementClient.js", "types": "./esm/storageManagementClient.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/storage/arm-storage-profile-2019-03-01-hybrid/src/storageManagementClient.ts b/sdk/storage/arm-storage-profile-2019-03-01-hybrid/src/storageManagementClient.ts index c14b7f11a76f..61b48769f0e3 100644 --- a/sdk/storage/arm-storage-profile-2019-03-01-hybrid/src/storageManagementClient.ts +++ b/sdk/storage/arm-storage-profile-2019-03-01-hybrid/src/storageManagementClient.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,12 +25,17 @@ class StorageManagementClient extends StorageManagementClientContext { /** * Initializes a new instance of the StorageManagementClient 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 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.StorageManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.StorageManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.skus = new operations.Skus(this); diff --git a/sdk/storage/arm-storage-profile-2019-03-01-hybrid/src/storageManagementClientContext.ts b/sdk/storage/arm-storage-profile-2019-03-01-hybrid/src/storageManagementClientContext.ts index 0dc8e6064c1a..dcd6e04a2a9d 100644 --- a/sdk/storage/arm-storage-profile-2019-03-01-hybrid/src/storageManagementClientContext.ts +++ b/sdk/storage/arm-storage-profile-2019-03-01-hybrid/src/storageManagementClientContext.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-storage-profile-2019-03-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class StorageManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the StorageManagementClient 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 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.StorageManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.StorageManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/storage/arm-storage/README.md b/sdk/storage/arm-storage/README.md index d95b62a15586..71fc9ecbee4a 100644 --- a/sdk/storage/arm-storage/README.md +++ b/sdk/storage/arm-storage/README.md @@ -1,89 +1,100 @@ ## Azure StorageManagementClient SDK for JavaScript -This package contains an isomorphic SDK for StorageManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for StorageManagementClient. ### 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-storage` 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-storage +npm install --save @azure/arm-storage @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 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. -- 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 operations 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 { StorageManagementClient } = require("@azure/arm-storage"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new StorageManagementClient(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 StorageManagementClient(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. -```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-storage sample - - + diff --git a/sdk/storage/arm-storage/package.json b/sdk/storage/arm-storage/package.json index f1ec9c4fe09c..e9dfee4fe9e6 100644 --- a/sdk/storage/arm-storage/package.json +++ b/sdk/storage/arm-storage/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-storage", "author": "Microsoft Corporation", "description": "StorageManagementClient Library with typescript type definitions for node.js and browser.", - "version": "16.0.0", + "version": "16.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/storageManagementClient.js", "types": "./esm/storageManagementClient.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/storage/arm-storage/src/storageManagementClient.ts b/sdk/storage/arm-storage/src/storageManagementClient.ts index 243688c40ba2..49219deb5668 100644 --- a/sdk/storage/arm-storage/src/storageManagementClient.ts +++ b/sdk/storage/arm-storage/src/storageManagementClient.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"; @@ -38,11 +39,16 @@ class StorageManagementClient extends StorageManagementClientContext { /** * Initializes a new instance of the StorageManagementClient 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.StorageManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.StorageManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.skus = new operations.Skus(this); diff --git a/sdk/storage/arm-storage/src/storageManagementClientContext.ts b/sdk/storage/arm-storage/src/storageManagementClientContext.ts index 6e9d9eefca84..59f62b7b557a 100644 --- a/sdk/storage/arm-storage/src/storageManagementClientContext.ts +++ b/sdk/storage/arm-storage/src/storageManagementClientContext.ts @@ -9,24 +9,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-storage"; -const packageVersion = "16.0.0"; +const packageVersion = "16.1.0"; export class StorageManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the StorageManagementClient 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, + credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.StorageManagementClientOptions ) {