diff --git a/sdk/peering/arm-peering/README.md b/sdk/peering/arm-peering/README.md index 8cfb0a190945..6386ca12a1da 100644 --- a/sdk/peering/arm-peering/README.md +++ b/sdk/peering/arm-peering/README.md @@ -1,94 +1,103 @@ ## Azure PeeringManagementClient SDK for JavaScript -This package contains an isomorphic SDK for PeeringManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for PeeringManagementClient. ### 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-peering` 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-peering +npm install --save @azure/arm-peering @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 legacyPeerings 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 legacyPeerings 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 { PeeringManagementClient, PeeringManagementModels, PeeringManagementMappers } from "@azure/arm-peering"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { PeeringManagementClient } = require("@azure/arm-peering"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new PeeringManagementClient(creds, subscriptionId); - const peeringLocation = "testpeeringLocation"; - const kind = "Direct"; - client.legacyPeerings.list(peeringLocation, kind).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 PeeringManagementClient(creds, subscriptionId); +const peeringLocation = "testpeeringLocation"; +const kind = "Direct"; +client.legacyPeerings.list(peeringLocation, kind).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 legacyPeerings as an example written in JavaScript. +#### browser - Authentication, client creation, and list legacyPeerings 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-peering sample - - + @@ -100,4 +109,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fpeering%2Farm-peering%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/peering/arm-peering/README.png) diff --git a/sdk/peering/arm-peering/package.json b/sdk/peering/arm-peering/package.json index c7c2b7e47341..5b286fc9c531 100644 --- a/sdk/peering/arm-peering/package.json +++ b/sdk/peering/arm-peering/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-peering", "author": "Microsoft Corporation", "description": "PeeringManagementClient 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/peeringManagementClient.js", "types": "./esm/peeringManagementClient.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/peering/arm-peering/src/peeringManagementClient.ts b/sdk/peering/arm-peering/src/peeringManagementClient.ts index bacf9dc4aabe..3fa8f9805ac7 100644 --- a/sdk/peering/arm-peering/src/peeringManagementClient.ts +++ b/sdk/peering/arm-peering/src/peeringManagementClient.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 Parameters from "./models/parameters"; @@ -31,11 +32,16 @@ class PeeringManagementClient extends PeeringManagementClientContext { /** * Initializes a new instance of the PeeringManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The Azure subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.PeeringManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PeeringManagementClientOptions) { super(credentials, subscriptionId, options); this.legacyPeerings = new operations.LegacyPeerings(this); this.operations = new operations.Operations(this); diff --git a/sdk/peering/arm-peering/src/peeringManagementClientContext.ts b/sdk/peering/arm-peering/src/peeringManagementClientContext.ts index 33fd6ae85bd7..ff6b10566b38 100644 --- a/sdk/peering/arm-peering/src/peeringManagementClientContext.ts +++ b/sdk/peering/arm-peering/src/peeringManagementClientContext.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-peering"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class PeeringManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the PeeringManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The Azure subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.PeeringManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PeeringManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/README.md b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/README.md index 277e5ca69bd8..d18fc2ab80ea 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/README.md +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/README.md @@ -1,92 +1,101 @@ ## Azure PolicyClient SDK for JavaScript -This package contains an isomorphic SDK for PolicyClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for PolicyClient. ### 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-policy-profile-2020-09-01-hybrid` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/arm-policy-profile-2020-09-01-hybrid +npm install --save @azure/arm-policy-profile-2020-09-01-hybrid @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and get policyDefinitions 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 policyDefinitions 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 { PolicyClient, PolicyModels, PolicyMappers } from "@azure/arm-policy-profile-2020-09-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { PolicyClient } = require("@azure/arm-policy-profile-2020-09-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new PolicyClient(creds, subscriptionId); - const policyDefinitionName = "testpolicyDefinitionName"; - client.policyDefinitions.get(policyDefinitionName).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 PolicyClient(creds, subscriptionId); +const policyDefinitionName = "testpolicyDefinitionName"; +client.policyDefinitions.get(policyDefinitionName).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 policyDefinitions as an example written in JavaScript. +#### browser - Authentication, client creation, and get policyDefinitions 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-policy-profile-2020-09-01-hybrid sample - - + diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/package.json b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/package.json index fe686de1fc7b..b1c67c0499f9 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/package.json +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-policy-profile-2020-09-01-hybrid", "author": "Microsoft Corporation", "description": "PolicyClient 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/policyClient.js", "types": "./esm/policyClient.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/policy/arm-policy-profile-2020-09-01-hybrid/src/policyClient.ts b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/policyClient.ts index 4a9606c77342..7891583c1cc0 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/policyClient.ts +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/policyClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -22,11 +23,16 @@ class PolicyClient extends PolicyClientContext { /** * Initializes a new instance of the PolicyClient 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.PolicyClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PolicyClientOptions) { super(credentials, subscriptionId, options); this.policyDefinitions = new operations.PolicyDefinitions(this); this.policyAssignments = new operations.PolicyAssignments(this); diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/policyClientContext.ts b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/policyClientContext.ts index 1982defbe797..9fe09efcdebd 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/policyClientContext.ts +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/policyClientContext.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-policy-profile-2020-09-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class PolicyClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the PolicyClient 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.PolicyClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PolicyClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/policy/arm-policy-profile-hybrid-2019-03-01/README.md b/sdk/policy/arm-policy-profile-hybrid-2019-03-01/README.md index 59229a76dfa7..88dd09df65aa 100644 --- a/sdk/policy/arm-policy-profile-hybrid-2019-03-01/README.md +++ b/sdk/policy/arm-policy-profile-hybrid-2019-03-01/README.md @@ -1,91 +1,101 @@ ## Azure PolicyClient SDK for JavaScript -This package contains an isomorphic SDK for PolicyClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for PolicyClient. ### 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-policy-profile-hybrid-2019-03-01` 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-policy-profile-hybrid-2019-03-01 +npm install --save @azure/arm-policy-profile-hybrid-2019-03-01 @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 policyDefinitions as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -```bash -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and get policyDefinitions 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 { PolicyClient, PolicyModels, PolicyMappers } from "@azure/arm-policy-profile-hybrid-2019-03-01"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { PolicyClient } = require("@azure/arm-policy-profile-hybrid-2019-03-01"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new PolicyClient(creds, subscriptionId); - const policyDefinitionName = "testpolicyDefinitionName"; - client.policyDefinitions.get(policyDefinitionName).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 PolicyClient(creds, subscriptionId); +const policyDefinitionName = "testpolicyDefinitionName"; +client.policyDefinitions.get(policyDefinitionName).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 policyDefinitions as an example written in JavaScript. +#### browser - Authentication, client creation, and get policyDefinitions 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-policy-profile-hybrid-2019-03-01 sample - - + @@ -97,5 +107,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fpolicy%2Farm-policy-profile-hybrid-2019-03-01%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/policy/arm-policy-profile-hybrid-2019-03-01/README.png) diff --git a/sdk/policy/arm-policy-profile-hybrid-2019-03-01/package.json b/sdk/policy/arm-policy-profile-hybrid-2019-03-01/package.json index 712ae64221a3..ded049860523 100644 --- a/sdk/policy/arm-policy-profile-hybrid-2019-03-01/package.json +++ b/sdk/policy/arm-policy-profile-hybrid-2019-03-01/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-policy-profile-hybrid-2019-03-01", "author": "Microsoft Corporation", "description": "PolicyClient 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/policyClient.js", "types": "./esm/policyClient.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/policy/arm-policy-profile-hybrid-2019-03-01/src/policyClient.ts b/sdk/policy/arm-policy-profile-hybrid-2019-03-01/src/policyClient.ts index 4a9606c77342..7891583c1cc0 100644 --- a/sdk/policy/arm-policy-profile-hybrid-2019-03-01/src/policyClient.ts +++ b/sdk/policy/arm-policy-profile-hybrid-2019-03-01/src/policyClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -22,11 +23,16 @@ class PolicyClient extends PolicyClientContext { /** * Initializes a new instance of the PolicyClient 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.PolicyClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PolicyClientOptions) { super(credentials, subscriptionId, options); this.policyDefinitions = new operations.PolicyDefinitions(this); this.policyAssignments = new operations.PolicyAssignments(this); diff --git a/sdk/policy/arm-policy-profile-hybrid-2019-03-01/src/policyClientContext.ts b/sdk/policy/arm-policy-profile-hybrid-2019-03-01/src/policyClientContext.ts index 5e2d978a2a8b..1b8ccc0ee7e9 100644 --- a/sdk/policy/arm-policy-profile-hybrid-2019-03-01/src/policyClientContext.ts +++ b/sdk/policy/arm-policy-profile-hybrid-2019-03-01/src/policyClientContext.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-policy-profile-hybrid-2019-03-01"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class PolicyClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the PolicyClient 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.PolicyClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PolicyClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/policy/arm-policy/README.md b/sdk/policy/arm-policy/README.md index ff6733dd79fd..e981a8c714fe 100644 --- a/sdk/policy/arm-policy/README.md +++ b/sdk/policy/arm-policy/README.md @@ -1,66 +1,74 @@ ## Azure PolicyClient SDK for JavaScript -This package contains an isomorphic SDK for PolicyClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for PolicyClient. ### 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-policy` 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-policy +npm install --save @azure/arm-policy @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 getByPolicyMode dataPolicyManifests 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 getByPolicyMode dataPolicyManifests 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 { PolicyClient } = require("@azure/arm-policy"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth - .interactiveLogin() - .then((creds) => { - const client = new PolicyClient(creds, subscriptionId); - const policyMode = "testpolicyMode"; - client.dataPolicyManifests.getByPolicyMode(policyMode).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 PolicyClient(creds, subscriptionId); +const policyMode = "testpolicyMode"; +client.dataPolicyManifests.getByPolicyMode(policyMode).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 getByPolicyMode dataPolicyManifests as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and getByPolicyMode dataPolicyManifests 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 @@ -68,33 +76,26 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to @azure/arm-policy sample - - + diff --git a/sdk/policy/arm-policy/package.json b/sdk/policy/arm-policy/package.json index e6934d947760..a5e321b7a066 100644 --- a/sdk/policy/arm-policy/package.json +++ b/sdk/policy/arm-policy/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-policy", "author": "Microsoft Corporation", "description": "PolicyClient 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/policyClient.js", "types": "./esm/policyClient.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/policy/arm-policy/src/policyClient.ts b/sdk/policy/arm-policy/src/policyClient.ts index 4b800b476a99..32b3a1885e4d 100644 --- a/sdk/policy/arm-policy/src/policyClient.ts +++ b/sdk/policy/arm-policy/src/policyClient.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"; @@ -23,12 +24,17 @@ class PolicyClient extends PolicyClientContext { /** * Initializes a new instance of the PolicyClient 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.PolicyClientOptions ) { diff --git a/sdk/policy/arm-policy/src/policyClientContext.ts b/sdk/policy/arm-policy/src/policyClientContext.ts index 2b09789e656d..eabd70d6762d 100644 --- a/sdk/policy/arm-policy/src/policyClientContext.ts +++ b/sdk/policy/arm-policy/src/policyClientContext.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-policy"; -const packageVersion = "4.0.0"; +const packageVersion = "4.1.0"; export class PolicyClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; /** * Initializes a new instance of the PolicyClient 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.PolicyClientOptions ) { diff --git a/sdk/policyinsights/arm-policyinsights/README.md b/sdk/policyinsights/arm-policyinsights/README.md index 6e4136a878bc..b87eda5db0db 100644 --- a/sdk/policyinsights/arm-policyinsights/README.md +++ b/sdk/policyinsights/arm-policyinsights/README.md @@ -1,95 +1,105 @@ ## Azure PolicyInsightsClient SDK for JavaScript -This package contains an isomorphic SDK for PolicyInsightsClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for PolicyInsightsClient. ### 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-policyinsights` 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-policyinsights +npm install --save @azure/arm-policyinsights @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 listForManagementGroup remediations 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 listForManagementGroup remediations 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 { PolicyInsightsClient } = require("@azure/arm-policyinsights"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new PolicyInsightsClient(creds, subscriptionId); - const managementGroupId = "testmanagementGroupId"; - const top = 1; - const filter = "testfilter"; - client.remediations.listForManagementGroup(managementGroupId, top, filter).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 PolicyInsightsClient(creds, subscriptionId); +const managementGroupId = "testmanagementGroupId"; +const top = 1; +const filter = "testfilter"; +client.remediations.listForManagementGroup(managementGroupId, top, filter).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 listForManagementGroup remediations as an example written in JavaScript. +#### browser - Authentication, client creation, and listForManagementGroup remediations 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-policyinsights sample - - + diff --git a/sdk/policyinsights/arm-policyinsights/package.json b/sdk/policyinsights/arm-policyinsights/package.json index 2d1a254b3b14..1e38d23a0c44 100644 --- a/sdk/policyinsights/arm-policyinsights/package.json +++ b/sdk/policyinsights/arm-policyinsights/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-policyinsights", "author": "Microsoft Corporation", "description": "PolicyInsightsClient 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/policyInsightsClient.js", "types": "./esm/policyInsightsClient.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/policyinsights/arm-policyinsights/src/policyInsightsClient.ts b/sdk/policyinsights/arm-policyinsights/src/policyInsightsClient.ts index 9a6e23996468..436f5db2eacb 100644 --- a/sdk/policyinsights/arm-policyinsights/src/policyInsightsClient.ts +++ b/sdk/policyinsights/arm-policyinsights/src/policyInsightsClient.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"; @@ -25,10 +26,15 @@ class PolicyInsightsClient extends PolicyInsightsClientContext { /** * Initializes a new instance of the PolicyInsightsClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.PolicyInsightsClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, options?: Models.PolicyInsightsClientOptions) { super(credentials, options); this.policyTrackedResources = new operations.PolicyTrackedResources(this); this.remediations = new operations.Remediations(this); diff --git a/sdk/policyinsights/arm-policyinsights/src/policyInsightsClientContext.ts b/sdk/policyinsights/arm-policyinsights/src/policyInsightsClientContext.ts index 8598034d32f8..f516548cf64e 100644 --- a/sdk/policyinsights/arm-policyinsights/src/policyInsightsClientContext.ts +++ b/sdk/policyinsights/arm-policyinsights/src/policyInsightsClientContext.ts @@ -9,20 +9,26 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-policyinsights"; -const packageVersion = "4.0.0"; +const packageVersion = "4.1.0"; export class PolicyInsightsClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; /** * Initializes a new instance of the PolicyInsightsClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.PolicyInsightsClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, options?: Models.PolicyInsightsClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/postgresql/arm-postgresql/README.md b/sdk/postgresql/arm-postgresql/README.md index 4894053e5749..70ce548880f8 100644 --- a/sdk/postgresql/arm-postgresql/README.md +++ b/sdk/postgresql/arm-postgresql/README.md @@ -1,93 +1,103 @@ ## Azure PostgreSQLManagementClient SDK for JavaScript -This package contains an isomorphic SDK for PostgreSQLManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for PostgreSQLManagementClient. ### 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-postgresql` 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-postgresql +npm install --save @azure/arm-postgresql @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 get servers as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- 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 servers 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 { PostgreSQLManagementClient } = require("@azure/arm-postgresql"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new PostgreSQLManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const serverName = "testserverName"; - client.servers.get(resourceGroupName, serverName).then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new PostgreSQLManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const serverName = "testserverName"; +client.servers.get(resourceGroupName, serverName).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and get servers as an example written in JavaScript. +#### browser - Authentication, client creation, and get servers as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-postgresql sample - - + diff --git a/sdk/postgresql/arm-postgresql/package.json b/sdk/postgresql/arm-postgresql/package.json index 985360d5fddb..2d8d44c2fba5 100644 --- a/sdk/postgresql/arm-postgresql/package.json +++ b/sdk/postgresql/arm-postgresql/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-postgresql", "author": "Microsoft Corporation", "description": "PostgreSQLManagementClient Library with typescript type definitions for node.js and browser.", - "version": "5.0.0", + "version": "5.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/postgreSQLManagementClient.js", "types": "./esm/postgreSQLManagementClient.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/postgresql/arm-postgresql/src/postgreSQLManagementClient.ts b/sdk/postgresql/arm-postgresql/src/postgreSQLManagementClient.ts index 3ce93955ee2c..6d38dc58f05b 100644 --- a/sdk/postgresql/arm-postgresql/src/postgreSQLManagementClient.ts +++ b/sdk/postgresql/arm-postgresql/src/postgreSQLManagementClient.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"; @@ -37,11 +38,16 @@ class PostgreSQLManagementClient extends PostgreSQLManagementClientContext { /** * Initializes a new instance of the PostgreSQLManagementClient 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.PostgreSQLManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PostgreSQLManagementClientOptions) { super(credentials, subscriptionId, options); this.servers = new operations.Servers(this); this.replicas = new operations.Replicas(this); diff --git a/sdk/postgresql/arm-postgresql/src/postgreSQLManagementClientContext.ts b/sdk/postgresql/arm-postgresql/src/postgreSQLManagementClientContext.ts index 7d2c5bb72738..63ae6996dc86 100644 --- a/sdk/postgresql/arm-postgresql/src/postgreSQLManagementClientContext.ts +++ b/sdk/postgresql/arm-postgresql/src/postgreSQLManagementClientContext.ts @@ -9,22 +9,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-postgresql"; -const packageVersion = "5.0.0"; +const packageVersion = "5.1.0"; export class PostgreSQLManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; /** * Initializes a new instance of the PostgreSQLManagementClient 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.PostgreSQLManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PostgreSQLManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/powerbidedicated/arm-powerbidedicated/README.md b/sdk/powerbidedicated/arm-powerbidedicated/README.md index e213b7d8b506..350863bc9ba0 100644 --- a/sdk/powerbidedicated/arm-powerbidedicated/README.md +++ b/sdk/powerbidedicated/arm-powerbidedicated/README.md @@ -1,94 +1,103 @@ ## Azure PowerBIDedicatedManagementClient SDK for JavaScript -This package contains an isomorphic SDK for PowerBIDedicatedManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for PowerBIDedicatedManagementClient. ### 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-powerbidedicated` 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-powerbidedicated +npm install --save @azure/arm-powerbidedicated @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 getDetails capacities 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 getDetails capacities 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 { PowerBIDedicatedManagementClient, PowerBIDedicatedManagementModels, PowerBIDedicatedManagementMappers } from "@azure/arm-powerbidedicated"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { PowerBIDedicatedManagementClient } = require("@azure/arm-powerbidedicated"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new PowerBIDedicatedManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const dedicatedCapacityName = "testdedicatedCapacityName"; - client.capacities.getDetails(resourceGroupName, dedicatedCapacityName).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 PowerBIDedicatedManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const dedicatedCapacityName = "testdedicatedCapacityName"; +client.capacities.getDetails(resourceGroupName, dedicatedCapacityName).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 getDetails capacities as an example written in JavaScript. +#### browser - Authentication, client creation, and getDetails capacities 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-powerbidedicated sample - - + diff --git a/sdk/powerbidedicated/arm-powerbidedicated/package.json b/sdk/powerbidedicated/arm-powerbidedicated/package.json index e9e3e8b3365b..4dc75966af4b 100644 --- a/sdk/powerbidedicated/arm-powerbidedicated/package.json +++ b/sdk/powerbidedicated/arm-powerbidedicated/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-powerbidedicated", "author": "Microsoft Corporation", "description": "PowerBIDedicatedManagementClient Library with typescript type definitions for node.js and browser.", - "version": "2.0.0", + "version": "2.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/powerBIDedicatedManagementClient.js", "types": "./esm/powerBIDedicatedManagementClient.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/powerbidedicated/arm-powerbidedicated/src/powerBIDedicatedManagementClient.ts b/sdk/powerbidedicated/arm-powerbidedicated/src/powerBIDedicatedManagementClient.ts index 33c72336bac6..eb7fcf046832 100644 --- a/sdk/powerbidedicated/arm-powerbidedicated/src/powerBIDedicatedManagementClient.ts +++ b/sdk/powerbidedicated/arm-powerbidedicated/src/powerBIDedicatedManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -22,12 +23,17 @@ class PowerBIDedicatedManagementClient extends PowerBIDedicatedManagementClientC /** * Initializes a new instance of the PowerBIDedicatedManagementClient 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 A unique identifier for 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.PowerBIDedicatedManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PowerBIDedicatedManagementClientOptions) { super(credentials, subscriptionId, options); this.capacities = new operations.Capacities(this); this.operations = new operations.Operations(this); diff --git a/sdk/powerbidedicated/arm-powerbidedicated/src/powerBIDedicatedManagementClientContext.ts b/sdk/powerbidedicated/arm-powerbidedicated/src/powerBIDedicatedManagementClientContext.ts index 8c2c324a10d1..0a9f748e5175 100644 --- a/sdk/powerbidedicated/arm-powerbidedicated/src/powerBIDedicatedManagementClientContext.ts +++ b/sdk/powerbidedicated/arm-powerbidedicated/src/powerBIDedicatedManagementClientContext.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-powerbidedicated"; -const packageVersion = "2.0.0"; +const packageVersion = "2.1.0"; export class PowerBIDedicatedManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the PowerBIDedicatedManagementClient 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 A unique identifier for 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.PowerBIDedicatedManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PowerBIDedicatedManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/powerbiembedded/arm-powerbiembedded/README.md b/sdk/powerbiembedded/arm-powerbiembedded/README.md index 9213827f768a..ac3cb55a27d4 100644 --- a/sdk/powerbiembedded/arm-powerbiembedded/README.md +++ b/sdk/powerbiembedded/arm-powerbiembedded/README.md @@ -1,93 +1,103 @@ ## Azure PowerBIEmbeddedManagementClient SDK for JavaScript -This package contains an isomorphic SDK for PowerBIEmbeddedManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for PowerBIEmbeddedManagementClient. ### 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-powerbiembedded +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-powerbiembedded` 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-powerbiembedded @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 getByName workspaceCollections 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 getByName workspaceCollections 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 { PowerBIEmbeddedManagementClient, PowerBIEmbeddedManagementModels, PowerBIEmbeddedManagementMappers } from "@azure/arm-powerbiembedded"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { PowerBIEmbeddedManagementClient } = require("@azure/arm-powerbiembedded"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new PowerBIEmbeddedManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const workspaceCollectionName = "testworkspaceCollectionName"; - client.workspaceCollections.getByName(resourceGroupName, workspaceCollectionName).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 PowerBIEmbeddedManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const workspaceCollectionName = "testworkspaceCollectionName"; +client.workspaceCollections.getByName(resourceGroupName, workspaceCollectionName).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 getByName workspaceCollections as an example written in JavaScript. +#### browser - Authentication, client creation, and getByName workspaceCollections as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -``` -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-powerbiembedded sample - - + @@ -99,5 +109,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fpowerbiembedded%2Farm-powerbiembedded%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/powerbiembedded/arm-powerbiembedded/README.png) diff --git a/sdk/powerbiembedded/arm-powerbiembedded/package.json b/sdk/powerbiembedded/arm-powerbiembedded/package.json index e4ca4e96d3d9..16accacf4be4 100644 --- a/sdk/powerbiembedded/arm-powerbiembedded/package.json +++ b/sdk/powerbiembedded/arm-powerbiembedded/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-powerbiembedded", "author": "Microsoft Corporation", "description": "PowerBIEmbeddedManagementClient Library with typescript type definitions for node.js and browser.", - "version": "1.2.0", + "version": "1.3.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.1.0", - "@azure/ms-rest-js": "^1.1.0", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/powerBIEmbeddedManagementClient.js", "types": "./esm/powerBIEmbeddedManagementClient.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/powerbiembedded/arm-powerbiembedded/src/powerBIEmbeddedManagementClient.ts b/sdk/powerbiembedded/arm-powerbiembedded/src/powerBIEmbeddedManagementClient.ts index a7d1e269bc37..3865970e8d99 100644 --- a/sdk/powerbiembedded/arm-powerbiembedded/src/powerBIEmbeddedManagementClient.ts +++ b/sdk/powerbiembedded/arm-powerbiembedded/src/powerBIEmbeddedManagementClient.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 Parameters from "./models/parameters"; @@ -23,12 +24,17 @@ class PowerBIEmbeddedManagementClient extends PowerBIEmbeddedManagementClientCon /** * Initializes a new instance of the PowerBIEmbeddedManagementClient 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 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.PowerBIEmbeddedManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PowerBIEmbeddedManagementClientOptions) { super(credentials, subscriptionId, options); this.workspaceCollections = new operations.WorkspaceCollections(this); this.workspaces = new operations.Workspaces(this); diff --git a/sdk/powerbiembedded/arm-powerbiembedded/src/powerBIEmbeddedManagementClientContext.ts b/sdk/powerbiembedded/arm-powerbiembedded/src/powerBIEmbeddedManagementClientContext.ts index d2974390607f..7492af897c70 100644 --- a/sdk/powerbiembedded/arm-powerbiembedded/src/powerBIEmbeddedManagementClientContext.ts +++ b/sdk/powerbiembedded/arm-powerbiembedded/src/powerBIEmbeddedManagementClientContext.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-powerbiembedded"; -const packageVersion = "0.1.0"; +const packageVersion = "1.3.0"; export class PowerBIEmbeddedManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the PowerBIEmbeddedManagementClient 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 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.PowerBIEmbeddedManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PowerBIEmbeddedManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/privatedns/arm-privatedns/README.md b/sdk/privatedns/arm-privatedns/README.md index 855aceddf7bb..c707eccceb75 100644 --- a/sdk/privatedns/arm-privatedns/README.md +++ b/sdk/privatedns/arm-privatedns/README.md @@ -1,94 +1,103 @@ ## Azure PrivateDnsManagementClient SDK for JavaScript -This package contains an isomorphic SDK for PrivateDnsManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for PrivateDnsManagementClient. ### 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-privatedns` 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-privatedns +npm install --save @azure/arm-privatedns @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 privateZones 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 privateZones 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 { PrivateDnsManagementClient, PrivateDnsManagementModels, PrivateDnsManagementMappers } from "@azure/arm-privatedns"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { PrivateDnsManagementClient } = require("@azure/arm-privatedns"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new PrivateDnsManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const privateZoneName = "testprivateZoneName"; - client.privateZones.get(resourceGroupName, privateZoneName).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 PrivateDnsManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const privateZoneName = "testprivateZoneName"; +client.privateZones.get(resourceGroupName, privateZoneName).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 privateZones as an example written in JavaScript. +#### browser - Authentication, client creation, and get privateZones 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-privatedns sample - - + diff --git a/sdk/privatedns/arm-privatedns/package.json b/sdk/privatedns/arm-privatedns/package.json index ce01d91428f5..adca1240dfb9 100644 --- a/sdk/privatedns/arm-privatedns/package.json +++ b/sdk/privatedns/arm-privatedns/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-privatedns", "author": "Microsoft Corporation", "description": "PrivateDnsManagementClient Library with typescript type definitions for node.js and browser.", - "version": "2.0.0", + "version": "2.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/privateDnsManagementClient.js", "types": "./esm/privateDnsManagementClient.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/privatedns/arm-privatedns/src/privateDnsManagementClient.ts b/sdk/privatedns/arm-privatedns/src/privateDnsManagementClient.ts index 7f3f6ceb4d13..17ca442b2bc3 100644 --- a/sdk/privatedns/arm-privatedns/src/privateDnsManagementClient.ts +++ b/sdk/privatedns/arm-privatedns/src/privateDnsManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -23,12 +24,17 @@ class PrivateDnsManagementClient extends PrivateDnsManagementClientContext { /** * Initializes a new instance of the PrivateDnsManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Gets subscription credentials which uniquely identify Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.PrivateDnsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PrivateDnsManagementClientOptions) { super(credentials, subscriptionId, options); this.privateZones = new operations.PrivateZones(this); this.virtualNetworkLinks = new operations.VirtualNetworkLinks(this); diff --git a/sdk/privatedns/arm-privatedns/src/privateDnsManagementClientContext.ts b/sdk/privatedns/arm-privatedns/src/privateDnsManagementClientContext.ts index 70b7dda90690..353a94c15772 100644 --- a/sdk/privatedns/arm-privatedns/src/privateDnsManagementClientContext.ts +++ b/sdk/privatedns/arm-privatedns/src/privateDnsManagementClientContext.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-privatedns"; -const packageVersion = "2.0.0"; +const packageVersion = "2.1.0"; export class PrivateDnsManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the PrivateDnsManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Gets subscription credentials which uniquely identify Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.PrivateDnsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.PrivateDnsManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); }