From 3c0e3d0bc2d90ca58938da742aeb3cedd1e13cd5 Mon Sep 17 00:00:00 2001 From: colawwj Date: Fri, 18 Jun 2021 10:57:25 +0800 Subject: [PATCH] arm-support-identity --- sdk/advisor/arm-advisor/README.md | 107 +++++++------- sdk/advisor/arm-advisor/package.json | 9 +- .../src/advisorManagementClient.ts | 10 +- .../src/advisorManagementClientContext.ts | 14 +- .../arm-analysisservices/README.md | 115 ++++++++------- .../arm-analysisservices/package.json | 9 +- .../src/analysisServicesManagementClient.ts | 10 +- ...analysisServicesManagementClientContext.ts | 14 +- sdk/apimanagement/arm-apimanagement/README.md | 128 +++++++++-------- .../arm-apimanagement/package.json | 9 +- .../src/apiManagementClient.ts | 10 +- .../src/apiManagementClientContext.ts | 14 +- .../arm-appconfiguration/README.md | 107 +++++++------- .../arm-appconfiguration/package.json | 9 +- .../src/appConfigurationManagementClient.ts | 10 +- ...appConfigurationManagementClientContext.ts | 14 +- .../arm-appinsights/README.md | 104 ++++++++------ .../arm-appinsights/package.json | 9 +- .../applicationInsightsManagementClient.ts | 10 +- ...licationInsightsManagementClientContext.ts | 14 +- sdk/appplatform/arm-appplatform/README.md | 108 +++++++------- sdk/appplatform/arm-appplatform/package.json | 9 +- .../src/appPlatformManagementClient.ts | 10 +- .../src/appPlatformManagementClientContext.ts | 14 +- .../README.md | 106 +++++++------- .../package.json | 9 +- .../src/webSiteManagementClient.ts | 10 +- .../src/webSiteManagementClientContext.ts | 14 +- .../README.md | 104 ++++++++------ .../package.json | 9 +- .../src/webSiteManagementClient.ts | 10 +- .../src/webSiteManagementClientContext.ts | 14 +- sdk/attestation/arm-attestation/README.md | 104 ++++++++------ sdk/attestation/arm-attestation/package.json | 9 +- .../src/attestationManagementClient.ts | 10 +- .../src/attestationManagementClientContext.ts | 14 +- .../README.md | 109 +++++++------- .../package.json | 9 +- .../src/authorizationManagementClient.ts | 10 +- .../authorizationManagementClientContext.ts | 14 +- .../README.md | 107 +++++++------- .../package.json | 9 +- .../src/authorizationManagementClient.ts | 10 +- .../authorizationManagementClientContext.ts | 14 +- sdk/authorization/arm-authorization/README.md | 113 ++++++++------- .../arm-authorization/package.json | 9 +- .../src/authorizationManagementClient.ts | 10 +- .../authorizationManagementClientContext.ts | 14 +- sdk/automation/arm-automation/README.md | 111 +++++++------- sdk/automation/arm-automation/package.json | 9 +- .../arm-automation/src/automationClient.ts | 10 +- .../src/automationClientContext.ts | 14 +- sdk/avs/arm-avs/README.md | 104 ++++++++------ sdk/avs/arm-avs/package.json | 9 +- sdk/avs/arm-avs/src/avsClient.ts | 10 +- sdk/avs/arm-avs/src/avsClientContext.ts | 14 +- sdk/azurestack/arm-azurestack/README.md | 104 ++++++++------ sdk/azurestack/arm-azurestack/package.json | 9 +- .../src/azureStackManagementClient.ts | 10 +- .../src/azureStackManagementClientContext.ts | 14 +- sdk/azurestackhci/arm-azurestackhci/README.md | 104 ++++++++------ .../arm-azurestackhci/package.json | 9 +- .../src/azureStackHCIClient.ts | 10 +- .../src/azureStackHCIClientContext.ts | 14 +- sdk/batch/arm-batch/README.md | 113 ++++++++------- sdk/batch/arm-batch/package.json | 9 +- .../arm-batch/src/batchManagementClient.ts | 10 +- .../src/batchManagementClientContext.ts | 14 +- sdk/batchai/arm-batchai/README.md | 108 +++++++------- sdk/batchai/arm-batchai/package.json | 9 +- .../src/batchAIManagementClient.ts | 10 +- .../src/batchAIManagementClientContext.ts | 14 +- sdk/billing/arm-billing/README.md | 111 +++++++------- sdk/billing/arm-billing/package.json | 9 +- .../src/billingManagementClient.ts | 10 +- .../src/billingManagementClientContext.ts | 14 +- sdk/botservice/arm-botservice/README.md | 111 +++++++------- sdk/botservice/arm-botservice/package.json | 9 +- .../arm-botservice/src/azureBotService.ts | 10 +- .../src/azureBotServiceContext.ts | 14 +- sdk/cdn/arm-cdn/README.md | 104 ++++++++------ sdk/cdn/arm-cdn/package.json | 9 +- sdk/cdn/arm-cdn/src/cdnManagementClient.ts | 10 +- .../arm-cdn/src/cdnManagementClientContext.ts | 14 +- .../arm-changeanalysis/README.md | 104 ++++++++------ .../arm-changeanalysis/package.json | 9 +- .../azureChangeAnalysisManagementClient.ts | 10 +- ...reChangeAnalysisManagementClientContext.ts | 14 +- .../README.md | 123 ++++++++-------- .../package.json | 9 +- .../src/usageManagementClient.ts | 10 +- .../src/usageManagementClientContext.ts | 14 +- sdk/commerce/arm-commerce/README.md | 125 ++++++++-------- sdk/commerce/arm-commerce/package.json | 9 +- .../arm-commerce/src/usageManagementClient.ts | 10 +- .../src/usageManagementClientContext.ts | 14 +- sdk/communication/arm-communication/README.md | 101 +++++++------ .../arm-communication/package.json | 9 +- .../communicationServiceManagementClient.ts | 10 +- ...unicationServiceManagementClientContext.ts | 14 +- .../README.md | 106 +++++++------- .../package.json | 9 +- .../src/computeManagementClient.ts | 10 +- .../src/computeManagementClientContext.ts | 14 +- .../README.md | 104 ++++++++------ .../package.json | 9 +- .../src/computeManagementClient.ts | 10 +- .../src/computeManagementClientContext.ts | 14 +- sdk/confluent/arm-confluent/README.md | 101 +++++++------ sdk/confluent/arm-confluent/package.json | 9 +- .../src/confluentManagementClient.ts | 10 +- .../src/confluentManagementClientContext.ts | 14 +- sdk/consumption/arm-consumption/README.md | 136 +++++++++--------- sdk/consumption/arm-consumption/package.json | 9 +- .../src/consumptionManagementClient.ts | 10 +- .../src/consumptionManagementClientContext.ts | 14 +- .../arm-containerinstance/README.md | 101 +++++++------ .../arm-containerinstance/package.json | 9 +- .../src/containerInstanceManagementClient.ts | 10 +- ...ontainerInstanceManagementClientContext.ts | 14 +- .../arm-containerregistry/README.md | 115 ++++++++------- .../arm-containerregistry/package.json | 9 +- .../src/containerRegistryManagementClient.ts | 10 +- ...ontainerRegistryManagementClientContext.ts | 14 +- .../arm-containerservice/README.md | 101 +++++++------ .../arm-containerservice/package.json | 9 +- .../src/containerServiceClient.ts | 10 +- .../src/containerServiceClientContext.ts | 14 +- .../arm-customerinsights/README.md | 108 +++++++------- .../arm-customerinsights/package.json | 9 +- .../src/customerInsightsManagementClient.ts | 10 +- ...customerInsightsManagementClientContext.ts | 14 +- sdk/databox/arm-databox/README.md | 104 ++++++++------ sdk/databox/arm-databox/package.json | 9 +- .../src/dataBoxManagementClient.ts | 10 +- .../src/dataBoxManagementClientContext.ts | 14 +- .../README.md | 104 ++++++++------ .../package.json | 9 +- .../src/dataBoxEdgeManagementClient.ts | 10 +- .../src/dataBoxEdgeManagementClientContext.ts | 14 +- sdk/databoxedge/arm-databoxedge/README.md | 104 ++++++++------ sdk/databoxedge/arm-databoxedge/package.json | 9 +- .../src/dataBoxEdgeManagementClient.ts | 10 +- .../src/dataBoxEdgeManagementClientContext.ts | 14 +- sdk/datacatalog/arm-datacatalog/README.md | 108 +++++++------- sdk/datacatalog/arm-datacatalog/package.json | 9 +- .../src/dataCatalogRestClient.ts | 10 +- .../src/dataCatalogRestClientContext.ts | 14 +- sdk/datadog/arm-datadog/README.md | 101 +++++++------ sdk/datadog/arm-datadog/package.json | 9 +- .../arm-datadog/src/microsoftDatadogClient.ts | 10 +- .../src/microsoftDatadogClientContext.ts | 14 +- .../arm-datalake-analytics/README.md | 124 ++++++++-------- .../arm-datalake-analytics/package.json | 9 +- ...ataLakeAnalyticsAccountManagementClient.ts | 10 +- ...AnalyticsAccountManagementClientContext.ts | 14 +- sdk/datamigration/arm-datamigration/README.md | 106 +++++++------- .../arm-datamigration/package.json | 9 +- .../src/dataMigrationServiceClient.ts | 10 +- .../src/dataMigrationServiceClientContext.ts | 14 +- .../arm-deploymentmanager/README.md | 111 +++++++------- .../arm-deploymentmanager/package.json | 9 +- .../src/azureDeploymentManager.ts | 10 +- .../src/azureDeploymentManagerContext.ts | 14 +- .../arm-deviceprovisioningservices/README.md | 108 +++++++------- .../package.json | 9 +- .../src/iotDpsClient.ts | 10 +- .../src/iotDpsClientContext.ts | 14 +- sdk/devspaces/arm-devspaces/README.md | 115 ++++++++------- sdk/devspaces/arm-devspaces/package.json | 9 +- .../src/devSpacesManagementClient.ts | 10 +- .../src/devSpacesManagementClientContext.ts | 14 +- sdk/devtestlabs/arm-devtestlabs/README.md | 106 +++++++------- sdk/devtestlabs/arm-devtestlabs/package.json | 9 +- .../arm-devtestlabs/src/devTestLabsClient.ts | 10 +- .../src/devTestLabsClientContext.ts | 14 +- sdk/digitaltwins/arm-digitaltwins/README.md | 108 +++++++------- .../arm-digitaltwins/package.json | 9 +- .../src/azureDigitalTwinsManagementClient.ts | 10 +- ...zureDigitalTwinsManagementClientContext.ts | 14 +- .../README.md | 121 ++++++++-------- .../package.json | 9 +- .../src/dnsManagementClient.ts | 10 +- .../src/dnsManagementClientContext.ts | 14 +- .../README.md | 119 ++++++++------- .../package.json | 9 +- .../src/dnsManagementClient.ts | 10 +- .../src/dnsManagementClientContext.ts | 14 +- sdk/dns/arm-dns/README.md | 119 ++++++++------- sdk/dns/arm-dns/package.json | 9 +- sdk/dns/arm-dns/src/dnsManagementClient.ts | 10 +- .../arm-dns/src/dnsManagementClientContext.ts | 14 +- .../arm-domainservices/README.md | 108 +++++++------- .../arm-domainservices/package.json | 9 +- .../src/domainservicesManagementClient.ts | 10 +- .../domainservicesManagementClientContext.ts | 14 +- 196 files changed, 4041 insertions(+), 2949 deletions(-) diff --git a/sdk/advisor/arm-advisor/README.md b/sdk/advisor/arm-advisor/README.md index 6e851c5fd17e..c78a674a386d 100644 --- a/sdk/advisor/arm-advisor/README.md +++ b/sdk/advisor/arm-advisor/README.md @@ -1,92 +1,101 @@ ## Azure AdvisorManagementClient SDK for JavaScript -This package contains an isomorphic SDK for AdvisorManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AdvisorManagementClient. ### 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-advisor` 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-advisor +npm install --save @azure/arm-advisor @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 recommendationMetadata 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 recommendationMetadata 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 { AdvisorManagementClient, AdvisorManagementModels, AdvisorManagementMappers } from "@azure/arm-advisor"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { AdvisorManagementClient } = require("@azure/arm-advisor"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AdvisorManagementClient(creds, subscriptionId); - const name = "testname"; - client.recommendationMetadata.get(name).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 AdvisorManagementClient(creds, subscriptionId); +const name = "testname"; +client.recommendationMetadata.get(name).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 recommendationMetadata as an example written in JavaScript. +#### browser - Authentication, client creation, and get recommendationMetadata 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-advisor sample - - + diff --git a/sdk/advisor/arm-advisor/package.json b/sdk/advisor/arm-advisor/package.json index a8157d573cae..f3dcccf69676 100644 --- a/sdk/advisor/arm-advisor/package.json +++ b/sdk/advisor/arm-advisor/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-advisor", "author": "Microsoft Corporation", "description": "AdvisorManagementClient 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/advisorManagementClient.js", "types": "./esm/advisorManagementClient.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/advisor/arm-advisor/src/advisorManagementClient.ts b/sdk/advisor/arm-advisor/src/advisorManagementClient.ts index a1de4884947a..4b888955a6a0 100644 --- a/sdk/advisor/arm-advisor/src/advisorManagementClient.ts +++ b/sdk/advisor/arm-advisor/src/advisorManagementClient.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"; @@ -25,11 +26,16 @@ class AdvisorManagementClient extends AdvisorManagementClientContext { /** * Initializes a new instance of the AdvisorManagementClient 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.AdvisorManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AdvisorManagementClientOptions) { super(credentials, subscriptionId, options); this.recommendationMetadata = new operations.RecommendationMetadata(this); this.configurations = new operations.Configurations(this); diff --git a/sdk/advisor/arm-advisor/src/advisorManagementClientContext.ts b/sdk/advisor/arm-advisor/src/advisorManagementClientContext.ts index e75f0e19b91c..7c8e091f169e 100644 --- a/sdk/advisor/arm-advisor/src/advisorManagementClientContext.ts +++ b/sdk/advisor/arm-advisor/src/advisorManagementClientContext.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-advisor"; -const packageVersion = "2.0.0"; +const packageVersion = "2.1.0"; export class AdvisorManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the AdvisorManagementClient 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.AdvisorManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AdvisorManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/analysisservices/arm-analysisservices/README.md b/sdk/analysisservices/arm-analysisservices/README.md index 516548f59279..ea44175bbb2e 100644 --- a/sdk/analysisservices/arm-analysisservices/README.md +++ b/sdk/analysisservices/arm-analysisservices/README.md @@ -1,93 +1,103 @@ ## Azure AnalysisServicesManagementClient SDK for JavaScript -This package contains an isomorphic SDK for AnalysisServicesManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AnalysisServicesManagementClient. ### 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-analysisservices +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-analysisservices` 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-analysisservices @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 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. -``` -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and getDetails servers 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 { AnalysisServicesManagementClient, AnalysisServicesManagementModels, AnalysisServicesManagementMappers } from "@azure/arm-analysisservices"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { AnalysisServicesManagementClient } = require("@azure/arm-analysisservices"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AnalysisServicesManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const serverName = "testserverName"; - client.servers.getDetails(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 AnalysisServicesManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const serverName = "testserverName"; +client.servers.getDetails(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 getDetails servers as an example written in JavaScript. +#### browser - Authentication, client creation, and getDetails servers 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-analysisservices 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%2Fanalysisservices%2Farm-analysisservices%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/analysisservices/arm-analysisservices/README.png) diff --git a/sdk/analysisservices/arm-analysisservices/package.json b/sdk/analysisservices/arm-analysisservices/package.json index e5fe81a5b910..b035e8002de1 100644 --- a/sdk/analysisservices/arm-analysisservices/package.json +++ b/sdk/analysisservices/arm-analysisservices/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-analysisservices", "author": "Microsoft Corporation", "description": "AnalysisServicesManagementClient Library with typescript type definitions for node.js and browser.", - "version": "2.3.2", + "version": "2.4.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/analysisServicesManagementClient.js", "types": "./esm/analysisServicesManagementClient.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/analysisservices/arm-analysisservices/src/analysisServicesManagementClient.ts b/sdk/analysisservices/arm-analysisservices/src/analysisServicesManagementClient.ts index 2d67bb6378b1..5d6c4d23ace8 100644 --- a/sdk/analysisservices/arm-analysisservices/src/analysisServicesManagementClient.ts +++ b/sdk/analysisservices/arm-analysisservices/src/analysisServicesManagementClient.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 AnalysisServicesManagementClient extends AnalysisServicesManagementClientC /** * Initializes a new instance of the AnalysisServicesManagementClient 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.AnalysisServicesManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AnalysisServicesManagementClientOptions) { super(credentials, subscriptionId, options); this.servers = new operations.Servers(this); this.operations = new operations.Operations(this); diff --git a/sdk/analysisservices/arm-analysisservices/src/analysisServicesManagementClientContext.ts b/sdk/analysisservices/arm-analysisservices/src/analysisServicesManagementClientContext.ts index e0ff9b6866ee..bc8d1b746e62 100644 --- a/sdk/analysisservices/arm-analysisservices/src/analysisServicesManagementClientContext.ts +++ b/sdk/analysisservices/arm-analysisservices/src/analysisServicesManagementClientContext.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-analysisservices"; -const packageVersion = "2.3.2"; +const packageVersion = "2.4.0"; export class AnalysisServicesManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the AnalysisServicesManagementClient 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.AnalysisServicesManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AnalysisServicesManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/apimanagement/arm-apimanagement/README.md b/sdk/apimanagement/arm-apimanagement/README.md index c72b1eb0a91b..8b269ab80915 100644 --- a/sdk/apimanagement/arm-apimanagement/README.md +++ b/sdk/apimanagement/arm-apimanagement/README.md @@ -1,103 +1,113 @@ ## Azure ApiManagementClient SDK for JavaScript -This package contains an isomorphic SDK for ApiManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ApiManagementClient. ### 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-apimanagement` 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-apimanagement +npm install --save @azure/arm-apimanagement @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 listByService api 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 listByService api 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 { ApiManagementClient } = require("@azure/arm-apimanagement"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ApiManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const serviceName = "testserviceName"; - const filter = "testfilter"; - const top = 1; - const skip = 1; - const tags = "testtags"; - const expandApiVersionSet = true; - client.api.listByService(resourceGroupName, serviceName, filter, top, skip, tags, expandApiVersionSet).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 ApiManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const serviceName = "testserviceName"; +const filter = "testfilter"; +const top = 1; +const skip = 1; +const tags = "testtags"; +const expandApiVersionSet = true; +client.api.listByService(resourceGroupName, serviceName, filter, top, skip, tags, expandApiVersionSet).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 listByService api as an example written in JavaScript. +#### browser - Authentication, client creation, and listByService api 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-apimanagement sample - - + diff --git a/sdk/apimanagement/arm-apimanagement/package.json b/sdk/apimanagement/arm-apimanagement/package.json index a998acb083b6..7d5af0afd50f 100644 --- a/sdk/apimanagement/arm-apimanagement/package.json +++ b/sdk/apimanagement/arm-apimanagement/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-apimanagement", "author": "Microsoft Corporation", "description": "ApiManagementClient Library with typescript type definitions for node.js and browser.", - "version": "7.0.0", + "version": "7.1.0", "dependencies": { - "@azure/ms-rest-azure-js": "^2.0.1", - "@azure/ms-rest-js": "^2.0.4", + "@azure/ms-rest-azure-js": "^2.1.0", + "@azure/ms-rest-js": "^2.2.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.10.0" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/apiManagementClient.js", "types": "./esm/apiManagementClient.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/apimanagement/arm-apimanagement/src/apiManagementClient.ts b/sdk/apimanagement/arm-apimanagement/src/apiManagementClient.ts index a94b91e45a04..43154573785a 100644 --- a/sdk/apimanagement/arm-apimanagement/src/apiManagementClient.ts +++ b/sdk/apimanagement/arm-apimanagement/src/apiManagementClient.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"; @@ -91,12 +92,17 @@ class ApiManagementClient extends ApiManagementClientContext { /** * Initializes a new instance of the ApiManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials 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.ApiManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ApiManagementClientOptions) { super(credentials, subscriptionId, options); this.api = new operations.Api(this); this.apiRevision = new operations.ApiRevision(this); diff --git a/sdk/apimanagement/arm-apimanagement/src/apiManagementClientContext.ts b/sdk/apimanagement/arm-apimanagement/src/apiManagementClientContext.ts index ae754b309f13..1da942a85c47 100644 --- a/sdk/apimanagement/arm-apimanagement/src/apiManagementClientContext.ts +++ b/sdk/apimanagement/arm-apimanagement/src/apiManagementClientContext.ts @@ -9,24 +9,30 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-apimanagement"; -const packageVersion = "7.0.0"; +const packageVersion = "7.1.0"; export class ApiManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the ApiManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials 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.ApiManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ApiManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/appconfiguration/arm-appconfiguration/README.md b/sdk/appconfiguration/arm-appconfiguration/README.md index 7b59569e1ed6..69b807098b23 100644 --- a/sdk/appconfiguration/arm-appconfiguration/README.md +++ b/sdk/appconfiguration/arm-appconfiguration/README.md @@ -1,92 +1,101 @@ ## Azure AppConfigurationManagementClient SDK for JavaScript -This package contains an isomorphic SDK for AppConfigurationManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AppConfigurationManagementClient. ### 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-appconfiguration` 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-appconfiguration +npm install --save @azure/arm-appconfiguration @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 configurationStores 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 configurationStores 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 { AppConfigurationManagementClient, AppConfigurationManagementModels, AppConfigurationManagementMappers } from "@azure/arm-appconfiguration"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { AppConfigurationManagementClient } = require("@azure/arm-appconfiguration"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AppConfigurationManagementClient(creds, subscriptionId); - const skipToken = "testskipToken"; - client.configurationStores.list(skipToken).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 AppConfigurationManagementClient(creds, subscriptionId); +const skipToken = "testskipToken"; +client.configurationStores.list(skipToken).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 configurationStores as an example written in JavaScript. +#### browser - Authentication, client creation, and list configurationStores 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-appconfiguration sample - - + diff --git a/sdk/appconfiguration/arm-appconfiguration/package.json b/sdk/appconfiguration/arm-appconfiguration/package.json index 26b7c0ec5092..6f81951910db 100644 --- a/sdk/appconfiguration/arm-appconfiguration/package.json +++ b/sdk/appconfiguration/arm-appconfiguration/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-appconfiguration", "author": "Microsoft Corporation", "description": "AppConfigurationManagementClient Library with typescript type definitions for node.js and browser.", - "version": "1.3.0", + "version": "1.4.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/appConfigurationManagementClient.js", "types": "./esm/appConfigurationManagementClient.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/appconfiguration/arm-appconfiguration/src/appConfigurationManagementClient.ts b/sdk/appconfiguration/arm-appconfiguration/src/appConfigurationManagementClient.ts index bc7c2ccf0f9c..b58eabc6d21f 100644 --- a/sdk/appconfiguration/arm-appconfiguration/src/appConfigurationManagementClient.ts +++ b/sdk/appconfiguration/arm-appconfiguration/src/appConfigurationManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -24,11 +25,16 @@ class AppConfigurationManagementClient extends AppConfigurationManagementClientC /** * Initializes a new instance of the AppConfigurationManagementClient 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 Microsoft Azure subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.AppConfigurationManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AppConfigurationManagementClientOptions) { super(credentials, subscriptionId, options); this.configurationStores = new operations.ConfigurationStores(this); this.operations = new operations.Operations(this); diff --git a/sdk/appconfiguration/arm-appconfiguration/src/appConfigurationManagementClientContext.ts b/sdk/appconfiguration/arm-appconfiguration/src/appConfigurationManagementClientContext.ts index bacdf7ad3cfa..72641b89d50e 100644 --- a/sdk/appconfiguration/arm-appconfiguration/src/appConfigurationManagementClientContext.ts +++ b/sdk/appconfiguration/arm-appconfiguration/src/appConfigurationManagementClientContext.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-appconfiguration"; -const packageVersion = "1.3.0"; +const packageVersion = "1.4.0"; export class AppConfigurationManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the AppConfigurationManagementClient 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 Microsoft Azure subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.AppConfigurationManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AppConfigurationManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/applicationinsights/arm-appinsights/README.md b/sdk/applicationinsights/arm-appinsights/README.md index a81a6333908d..4b865a5e2981 100644 --- a/sdk/applicationinsights/arm-appinsights/README.md +++ b/sdk/applicationinsights/arm-appinsights/README.md @@ -1,90 +1,100 @@ ## Azure ApplicationInsightsManagementClient SDK for JavaScript -This package contains an isomorphic SDK for ApplicationInsightsManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ApplicationInsightsManagementClient. ### 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-appinsights` 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-appinsights +npm install --save @azure/arm-appinsights @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { ApplicationInsightsManagementClient, ApplicationInsightsManagementModels, ApplicationInsightsManagementMappers } from "@azure/arm-appinsights"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { ApplicationInsightsManagementClient } = require("@azure/arm-appinsights"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ApplicationInsightsManagementClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new ApplicationInsightsManagementClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-appinsights sample - - + diff --git a/sdk/applicationinsights/arm-appinsights/package.json b/sdk/applicationinsights/arm-appinsights/package.json index 7c57385ff716..80a232e130be 100644 --- a/sdk/applicationinsights/arm-appinsights/package.json +++ b/sdk/applicationinsights/arm-appinsights/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-appinsights", "author": "Microsoft Corporation", "description": "ApplicationInsightsManagementClient Library with typescript type definitions for node.js and browser.", - "version": "3.0.0", + "version": "3.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/applicationInsightsManagementClient.js", "types": "./esm/applicationInsightsManagementClient.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/applicationinsights/arm-appinsights/src/applicationInsightsManagementClient.ts b/sdk/applicationinsights/arm-appinsights/src/applicationInsightsManagementClient.ts index 129814529633..e001f89b1329 100644 --- a/sdk/applicationinsights/arm-appinsights/src/applicationInsightsManagementClient.ts +++ b/sdk/applicationinsights/arm-appinsights/src/applicationInsightsManagementClient.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"; @@ -39,11 +40,16 @@ class ApplicationInsightsManagementClient extends ApplicationInsightsManagementC /** * Initializes a new instance of the ApplicationInsightsManagementClient 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.ApplicationInsightsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ApplicationInsightsManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.annotations = new operations.Annotations(this); diff --git a/sdk/applicationinsights/arm-appinsights/src/applicationInsightsManagementClientContext.ts b/sdk/applicationinsights/arm-appinsights/src/applicationInsightsManagementClientContext.ts index 14021c83aee1..b3cc5d676aba 100644 --- a/sdk/applicationinsights/arm-appinsights/src/applicationInsightsManagementClientContext.ts +++ b/sdk/applicationinsights/arm-appinsights/src/applicationInsightsManagementClientContext.ts @@ -10,22 +10,28 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-appinsights"; -const packageVersion = "3.0.0"; +const packageVersion = "3.1.0"; export class ApplicationInsightsManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; /** * Initializes a new instance of the ApplicationInsightsManagementClient 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.ApplicationInsightsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ApplicationInsightsManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/appplatform/arm-appplatform/README.md b/sdk/appplatform/arm-appplatform/README.md index f05562f618da..c06e938283f7 100644 --- a/sdk/appplatform/arm-appplatform/README.md +++ b/sdk/appplatform/arm-appplatform/README.md @@ -1,93 +1,103 @@ ## Azure AppPlatformManagementClient SDK for JavaScript -This package contains an isomorphic SDK for AppPlatformManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AppPlatformManagementClient. ### 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-appplatform` 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-appplatform +npm install --save @azure/arm-appplatform @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 services 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 services 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 { AppPlatformManagementClient } = require("@azure/arm-appplatform"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AppPlatformManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const serviceName = "testserviceName"; - client.services.get(resourceGroupName, serviceName).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 AppPlatformManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const serviceName = "testserviceName"; +client.services.get(resourceGroupName, serviceName).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 services as an example written in JavaScript. +#### browser - Authentication, client creation, and get services 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-appplatform sample - - + diff --git a/sdk/appplatform/arm-appplatform/package.json b/sdk/appplatform/arm-appplatform/package.json index ebab866401ae..a06921a62ed4 100644 --- a/sdk/appplatform/arm-appplatform/package.json +++ b/sdk/appplatform/arm-appplatform/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-appplatform", "author": "Microsoft Corporation", "description": "AppPlatformManagementClient Library with typescript type definitions for node.js and browser.", - "version": "1.2.0", + "version": "1.3.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/appPlatformManagementClient.js", "types": "./esm/appPlatformManagementClient.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/appplatform/arm-appplatform/src/appPlatformManagementClient.ts b/sdk/appplatform/arm-appplatform/src/appPlatformManagementClient.ts index e9bef8750f6f..a942c7ed14c8 100644 --- a/sdk/appplatform/arm-appplatform/src/appPlatformManagementClient.ts +++ b/sdk/appplatform/arm-appplatform/src/appPlatformManagementClient.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"; @@ -30,12 +31,17 @@ class AppPlatformManagementClient extends AppPlatformManagementClientContext { /** * Initializes a new instance of the AppPlatformManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Gets subscription ID which uniquely identify the Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.AppPlatformManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AppPlatformManagementClientOptions) { super(credentials, subscriptionId, options); this.services = new operations.Services(this); this.configServers = new operations.ConfigServers(this); diff --git a/sdk/appplatform/arm-appplatform/src/appPlatformManagementClientContext.ts b/sdk/appplatform/arm-appplatform/src/appPlatformManagementClientContext.ts index 6e107e7e50bf..1c6af685d8ac 100644 --- a/sdk/appplatform/arm-appplatform/src/appPlatformManagementClientContext.ts +++ b/sdk/appplatform/arm-appplatform/src/appPlatformManagementClientContext.ts @@ -9,24 +9,30 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-appplatform"; -const packageVersion = "1.2.0"; +const packageVersion = "1.3.0"; export class AppPlatformManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the AppPlatformManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Gets subscription ID which uniquely identify the Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.AppPlatformManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AppPlatformManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/README.md b/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/README.md index 3ffb61bd731e..26137bf2bd28 100644 --- a/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/README.md +++ b/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/README.md @@ -1,89 +1,100 @@ ## Azure WebSiteManagementClient SDK for JavaScript -This package contains an isomorphic SDK for WebSiteManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for WebSiteManagementClient. ### 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-appservice-profile-2019-03-01-hybrid` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/arm-appservice-profile-2019-03-01-hybrid +npm install --save @azure/arm-appservice-profile-2019-03-01-hybrid @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list certificates as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -```bash -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list certificates 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 { WebSiteManagementClient, WebSiteManagementModels, WebSiteManagementMappers } from "@azure/arm-appservice-profile-2019-03-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { WebSiteManagementClient } = require("@azure/arm-appservice-profile-2019-03-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new WebSiteManagementClient(creds, subscriptionId); - client.certificates.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new WebSiteManagementClient(creds, subscriptionId); + +client.certificates.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list certificates as an example written in JavaScript. +#### browser - Authentication, client creation, and list certificates 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-appservice-profile-2019-03-01-hybrid sample - - + @@ -95,5 +106,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fappservice%2Farm-appservice-profile-2019-03-01-hybrid%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/README.png) diff --git a/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/package.json b/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/package.json index 703c41e0442c..952a9bb98d08 100644 --- a/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/package.json +++ b/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-appservice-profile-2019-03-01-hybrid", "author": "Microsoft Corporation", "description": "WebSiteManagementClient Library with typescript type definitions for node.js and browser.", - "version": "1.0.0", + "version": "1.1.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.3.2", - "@azure/ms-rest-js": "^1.8.1", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/webSiteManagementClient.js", "types": "./esm/webSiteManagementClient.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/appservice/arm-appservice-profile-2019-03-01-hybrid/src/webSiteManagementClient.ts b/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/src/webSiteManagementClient.ts index 0d35a9177b82..0d640ce71d6e 100644 --- a/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/src/webSiteManagementClient.ts +++ b/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/src/webSiteManagementClient.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"; @@ -26,12 +27,17 @@ class WebSiteManagementClient extends WebSiteManagementClientContext { /** * Initializes a new instance of the WebSiteManagementClient 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 Your Azure subscription ID. This is a GUID-formatted string (e.g. * 00000000-0000-0000-0000-000000000000). * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.WebSiteManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.WebSiteManagementClientOptions) { super(credentials, subscriptionId, options); this.certificates = new operations.Certificates(this); this.webApps = new operations.WebApps(this); diff --git a/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/src/webSiteManagementClientContext.ts b/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/src/webSiteManagementClientContext.ts index 009c37bd2c6b..b8db44f5ff74 100644 --- a/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/src/webSiteManagementClientContext.ts +++ b/sdk/appservice/arm-appservice-profile-2019-03-01-hybrid/src/webSiteManagementClientContext.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-appservice-profile-2019-03-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class WebSiteManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the WebSiteManagementClient 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 Your Azure subscription ID. This is a GUID-formatted string (e.g. * 00000000-0000-0000-0000-000000000000). * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.WebSiteManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.WebSiteManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/README.md b/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/README.md index c423f466f6e1..aa27aa0db8b6 100644 --- a/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/README.md +++ b/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/README.md @@ -1,90 +1,100 @@ ## Azure WebSiteManagementClient SDK for JavaScript -This package contains an isomorphic SDK for WebSiteManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for WebSiteManagementClient. ### 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-appservice-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-appservice-profile-2020-09-01-hybrid +npm install --save @azure/arm-appservice-profile-2020-09-01-hybrid @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list certificates 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 certificates 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 { WebSiteManagementClient, WebSiteManagementModels, WebSiteManagementMappers } from "@azure/arm-appservice-profile-2020-09-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { WebSiteManagementClient } = require("@azure/arm-appservice-profile-2020-09-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new WebSiteManagementClient(creds, subscriptionId); - client.certificates.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new WebSiteManagementClient(creds, subscriptionId); + +client.certificates.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list certificates as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list certificates as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-appservice-profile-2020-09-01-hybrid sample - - + diff --git a/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/package.json b/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/package.json index c9d9463cfb6f..277da139be4d 100644 --- a/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/package.json +++ b/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-appservice-profile-2020-09-01-hybrid", "author": "Microsoft Corporation", "description": "WebSiteManagementClient 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/webSiteManagementClient.js", "types": "./esm/webSiteManagementClient.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/appservice/arm-appservice-profile-2020-09-01-hybrid/src/webSiteManagementClient.ts b/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/src/webSiteManagementClient.ts index 0d35a9177b82..0d640ce71d6e 100644 --- a/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/src/webSiteManagementClient.ts +++ b/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/src/webSiteManagementClient.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"; @@ -26,12 +27,17 @@ class WebSiteManagementClient extends WebSiteManagementClientContext { /** * Initializes a new instance of the WebSiteManagementClient 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 Your Azure subscription ID. This is a GUID-formatted string (e.g. * 00000000-0000-0000-0000-000000000000). * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.WebSiteManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.WebSiteManagementClientOptions) { super(credentials, subscriptionId, options); this.certificates = new operations.Certificates(this); this.webApps = new operations.WebApps(this); diff --git a/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/src/webSiteManagementClientContext.ts b/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/src/webSiteManagementClientContext.ts index ffc50ad7fc59..76232c9ebc0b 100644 --- a/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/src/webSiteManagementClientContext.ts +++ b/sdk/appservice/arm-appservice-profile-2020-09-01-hybrid/src/webSiteManagementClientContext.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-appservice-profile-2020-09-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class WebSiteManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the WebSiteManagementClient 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 Your Azure subscription ID. This is a GUID-formatted string (e.g. * 00000000-0000-0000-0000-000000000000). * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.WebSiteManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.WebSiteManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/attestation/arm-attestation/README.md b/sdk/attestation/arm-attestation/README.md index 08a634ff796d..e26c14c75674 100644 --- a/sdk/attestation/arm-attestation/README.md +++ b/sdk/attestation/arm-attestation/README.md @@ -1,90 +1,100 @@ ## Azure AttestationManagementClient SDK for JavaScript -This package contains an isomorphic SDK for AttestationManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AttestationManagementClient. ### 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-attestation` 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-attestation +npm install --save @azure/arm-attestation @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { AttestationManagementClient, AttestationManagementModels, AttestationManagementMappers } from "@azure/arm-attestation"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { AttestationManagementClient } = require("@azure/arm-attestation"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AttestationManagementClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new AttestationManagementClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-attestation sample - - + diff --git a/sdk/attestation/arm-attestation/package.json b/sdk/attestation/arm-attestation/package.json index 109eab318b34..ac8a0e7a0ae4 100644 --- a/sdk/attestation/arm-attestation/package.json +++ b/sdk/attestation/arm-attestation/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-attestation", "author": "Microsoft Corporation", "description": "AttestationManagementClient 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/attestationManagementClient.js", "types": "./esm/attestationManagementClient.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/attestation/arm-attestation/src/attestationManagementClient.ts b/sdk/attestation/arm-attestation/src/attestationManagementClient.ts index 1657aee1b92f..ab2f54efb640 100644 --- a/sdk/attestation/arm-attestation/src/attestationManagementClient.ts +++ b/sdk/attestation/arm-attestation/src/attestationManagementClient.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 AttestationManagementClient extends AttestationManagementClientContext { /** * Initializes a new instance of the AttestationManagementClient 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.AttestationManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AttestationManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.attestationProviders = new operations.AttestationProviders(this); diff --git a/sdk/attestation/arm-attestation/src/attestationManagementClientContext.ts b/sdk/attestation/arm-attestation/src/attestationManagementClientContext.ts index c07885699d86..c094c4cfbaa1 100644 --- a/sdk/attestation/arm-attestation/src/attestationManagementClientContext.ts +++ b/sdk/attestation/arm-attestation/src/attestationManagementClientContext.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-attestation"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class AttestationManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the AttestationManagementClient 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.AttestationManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AttestationManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/README.md b/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/README.md index 1c27e64535b1..09b24f40d9bc 100644 --- a/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/README.md +++ b/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/README.md @@ -1,91 +1,101 @@ ## Azure AuthorizationManagementClient SDK for JavaScript -This package contains an isomorphic SDK for AuthorizationManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AuthorizationManagementClient. ### 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-authorization-profile-2019-03-01-hybrid` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/arm-authorization-profile-2019-03-01-hybrid +npm install --save @azure/arm-authorization-profile-2019-03-01-hybrid @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and listForResourceGroup permissions 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 listForResourceGroup permissions 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 { AuthorizationManagementClient, AuthorizationManagementModels, AuthorizationManagementMappers } from "@azure/arm-authorization-profile-2019-03-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { AuthorizationManagementClient } = require("@azure/arm-authorization-profile-2019-03-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AuthorizationManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - client.permissions.listForResourceGroup(resourceGroupName).then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new AuthorizationManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +client.permissions.listForResourceGroup(resourceGroupName).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and listForResourceGroup permissions as an example written in JavaScript. +#### browser - Authentication, client creation, and listForResourceGroup permissions 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-authorization-profile-2019-03-01-hybrid 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%2Fauthorization%2Farm-authorization-profile-2019-03-01-hybrid%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/README.png) diff --git a/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/package.json b/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/package.json index 91c633edea0b..87781da4466f 100644 --- a/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/package.json +++ b/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-authorization-profile-2019-03-01-hybrid", "author": "Microsoft Corporation", "description": "AuthorizationManagementClient 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/authorizationManagementClient.js", "types": "./esm/authorizationManagementClient.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/authorization/arm-authorization-profile-2019-03-01-hybrid/src/authorizationManagementClient.ts b/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/src/authorizationManagementClient.ts index 2c27b1a41c0c..3f9befd01c0e 100644 --- a/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/src/authorizationManagementClient.ts +++ b/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/src/authorizationManagementClient.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"; @@ -25,11 +26,16 @@ class AuthorizationManagementClient extends AuthorizationManagementClientContext /** * Initializes a new instance of the AuthorizationManagementClient 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.AuthorizationManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AuthorizationManagementClientOptions) { super(credentials, subscriptionId, options); this.permissions = new operations.Permissions(this); this.providerOperationsMetadata = new operations.ProviderOperationsMetadataOperations(this); diff --git a/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/src/authorizationManagementClientContext.ts b/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/src/authorizationManagementClientContext.ts index 06325eb70e3c..1e7113ab7019 100644 --- a/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/src/authorizationManagementClientContext.ts +++ b/sdk/authorization/arm-authorization-profile-2019-03-01-hybrid/src/authorizationManagementClientContext.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-authorization-profile-2019-03-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class AuthorizationManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the AuthorizationManagementClient 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.AuthorizationManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AuthorizationManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/README.md b/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/README.md index f4515cf204e2..de209d61a2e6 100644 --- a/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/README.md +++ b/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/README.md @@ -1,92 +1,101 @@ ## Azure AuthorizationManagementClient SDK for JavaScript -This package contains an isomorphic SDK for AuthorizationManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AuthorizationManagementClient. ### 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-authorization-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-authorization-profile-2020-09-01-hybrid +npm install --save @azure/arm-authorization-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 listForResourceGroup permissions 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 listForResourceGroup permissions 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 { AuthorizationManagementClient, AuthorizationManagementModels, AuthorizationManagementMappers } from "@azure/arm-authorization-profile-2020-09-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { AuthorizationManagementClient } = require("@azure/arm-authorization-profile-2020-09-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AuthorizationManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - client.permissions.listForResourceGroup(resourceGroupName).then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new AuthorizationManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +client.permissions.listForResourceGroup(resourceGroupName).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and listForResourceGroup permissions as an example written in JavaScript. +#### browser - Authentication, client creation, and listForResourceGroup permissions 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-authorization-profile-2020-09-01-hybrid sample - - + diff --git a/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/package.json b/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/package.json index 7e57bafabb39..0a37484339f3 100644 --- a/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/package.json +++ b/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-authorization-profile-2020-09-01-hybrid", "author": "Microsoft Corporation", "description": "AuthorizationManagementClient 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/authorizationManagementClient.js", "types": "./esm/authorizationManagementClient.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/authorization/arm-authorization-profile-2020-09-01-hybrid/src/authorizationManagementClient.ts b/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/src/authorizationManagementClient.ts index a1aded5211b9..2164fe797036 100644 --- a/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/src/authorizationManagementClient.ts +++ b/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/src/authorizationManagementClient.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"; @@ -25,11 +26,16 @@ class AuthorizationManagementClient extends AuthorizationManagementClientContext /** * Initializes a new instance of the AuthorizationManagementClient 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.AuthorizationManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AuthorizationManagementClientOptions) { super(credentials, subscriptionId, options); this.permissions = new operations.Permissions(this); this.roleDefinitions = new operations.RoleDefinitions(this); diff --git a/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/src/authorizationManagementClientContext.ts b/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/src/authorizationManagementClientContext.ts index a3a07b227f8b..624b843cabad 100644 --- a/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/src/authorizationManagementClientContext.ts +++ b/sdk/authorization/arm-authorization-profile-2020-09-01-hybrid/src/authorizationManagementClientContext.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-authorization-profile-2020-09-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class AuthorizationManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the AuthorizationManagementClient 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.AuthorizationManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AuthorizationManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/authorization/arm-authorization/README.md b/sdk/authorization/arm-authorization/README.md index 00b867f0df83..97a2b1e7248b 100644 --- a/sdk/authorization/arm-authorization/README.md +++ b/sdk/authorization/arm-authorization/README.md @@ -1,61 +1,74 @@ ## Azure AuthorizationManagementClient SDK for JavaScript -This package contains an isomorphic SDK for AuthorizationManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AuthorizationManagementClient. ### 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-authorization` 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-authorization +npm install --save @azure/arm-authorization @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 classicAdministrators as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -```bash -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list classicAdministrators as an example written in JavaScript. ##### Sample code ```javascript +const { DefaultAzureCredential } = require("@azure/identity"); const { AuthorizationManagementClient } = require("@azure/arm-authorization"); -const { interactiveLogin } = require("@azure/ms-rest-nodeauth"); - const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -interactiveLogin() - .then((creds) => { - const client = new AuthorizationManagementClient(creds, subscriptionId); - client.classicAdministrators.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); - }) - .catch((err) => { - console.error(err); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new AuthorizationManagementClient(creds, subscriptionId); + +client.classicAdministrators.list().then((result) => { + console.log("The result is:"); + console.log(result); +}).catch((err) => { + console.log("An error occurred:"); + console.error(err); +}); ``` -#### browser - Authentication, client creation and list classicAdministrators as an example written in JavaScript. +#### browser - Authentication, client creation, and list classicAdministrators 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 @@ -63,35 +76,25 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to @azure/arm-authorization sample - - + @@ -103,4 +106,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fauthorization%2Farm-authorization%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/authorization/arm-authorization/README.png) diff --git a/sdk/authorization/arm-authorization/package.json b/sdk/authorization/arm-authorization/package.json index e8c1c708f434..88d8e11426ec 100644 --- a/sdk/authorization/arm-authorization/package.json +++ b/sdk/authorization/arm-authorization/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-authorization", "author": "Microsoft Corporation", "description": "AuthorizationManagementClient Library with typescript type definitions for node.js and browser.", - "version": "8.3.3", + "version": "8.4.0", "dependencies": { - "@azure/ms-rest-azure-js": "^2.0.0", - "@azure/ms-rest-js": "^2.0.3", + "@azure/ms-rest-azure-js": "^2.1.0", + "@azure/ms-rest-js": "^2.2.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/authorizationManagementClient.js", "types": "./esm/authorizationManagementClient.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/authorization/arm-authorization/src/authorizationManagementClient.ts b/sdk/authorization/arm-authorization/src/authorizationManagementClient.ts index 38d6e007d768..b970948c40cb 100644 --- a/sdk/authorization/arm-authorization/src/authorizationManagementClient.ts +++ b/sdk/authorization/arm-authorization/src/authorizationManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -27,11 +28,16 @@ class AuthorizationManagementClient extends AuthorizationManagementClientContext /** * Initializes a new instance of the AuthorizationManagementClient 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.AuthorizationManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AuthorizationManagementClientOptions) { super(credentials, subscriptionId, options); this.classicAdministrators = new operations.ClassicAdministrators(this); this.globalAdministrator = new operations.GlobalAdministrator(this); diff --git a/sdk/authorization/arm-authorization/src/authorizationManagementClientContext.ts b/sdk/authorization/arm-authorization/src/authorizationManagementClientContext.ts index 2b1aabd7fe6c..d81273824f92 100644 --- a/sdk/authorization/arm-authorization/src/authorizationManagementClientContext.ts +++ b/sdk/authorization/arm-authorization/src/authorizationManagementClientContext.ts @@ -10,22 +10,28 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-authorization"; -const packageVersion = "8.3.3"; +const packageVersion = "8.4.0"; export class AuthorizationManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; /** * Initializes a new instance of the AuthorizationManagementClient 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.AuthorizationManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AuthorizationManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/automation/arm-automation/README.md b/sdk/automation/arm-automation/README.md index 50b1d40caaa1..d7548d60e4c8 100644 --- a/sdk/automation/arm-automation/README.md +++ b/sdk/automation/arm-automation/README.md @@ -1,94 +1,103 @@ ## Azure AutomationClient SDK for JavaScript -This package contains an isomorphic SDK for AutomationClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AutomationClient. ### 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-automation` 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-automation +npm install --save @azure/arm-automation @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 automationAccount 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 automationAccount 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 { AutomationClient, AutomationModels, AutomationMappers } from "@azure/arm-automation"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { AutomationClient } = require("@azure/arm-automation"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AutomationClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const automationAccountName = "testautomationAccountName"; - client.automationAccount.get(resourceGroupName, automationAccountName).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 AutomationClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const automationAccountName = "testautomationAccountName"; +client.automationAccount.get(resourceGroupName, automationAccountName).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 automationAccount as an example written in JavaScript. +#### browser - Authentication, client creation, and get automationAccount 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-automation sample - - + diff --git a/sdk/automation/arm-automation/package.json b/sdk/automation/arm-automation/package.json index 3c834e3fe06c..91183c924834 100644 --- a/sdk/automation/arm-automation/package.json +++ b/sdk/automation/arm-automation/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-automation", "author": "Microsoft Corporation", "description": "AutomationClient Library with typescript type definitions for node.js and browser.", - "version": "10.0.0", + "version": "10.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/automationClient.js", "types": "./esm/automationClient.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/automation/arm-automation/src/automationClient.ts b/sdk/automation/arm-automation/src/automationClient.ts index 4290b4b4a1c7..20f3495cf384 100644 --- a/sdk/automation/arm-automation/src/automationClient.ts +++ b/sdk/automation/arm-automation/src/automationClient.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"; @@ -61,14 +62,19 @@ class AutomationClient extends AutomationClientContext { /** * Initializes a new instance of the AutomationClient 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 countType1 The type of counts to retrieve. Possible values include: 'status', * 'nodeconfiguration' * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, countType1: Models.CountType, options?: Models.AutomationClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, countType1: Models.CountType, options?: Models.AutomationClientOptions) { super(credentials, subscriptionId, countType1, options); this.automationAccount = new operations.AutomationAccountOperations(this); this.operations = new operations.Operations(this); diff --git a/sdk/automation/arm-automation/src/automationClientContext.ts b/sdk/automation/arm-automation/src/automationClientContext.ts index 52193c535a17..b686a363373a 100644 --- a/sdk/automation/arm-automation/src/automationClientContext.ts +++ b/sdk/automation/arm-automation/src/automationClientContext.ts @@ -10,26 +10,32 @@ 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-automation"; -const packageVersion = "10.0.0"; +const packageVersion = "10.1.0"; export class AutomationClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; countType1: Models.CountType; /** * Initializes a new instance of the AutomationClient 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 countType1 The type of counts to retrieve. Possible values include: 'status', * 'nodeconfiguration' * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, countType1: Models.CountType, options?: Models.AutomationClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, countType1: Models.CountType, options?: Models.AutomationClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/avs/arm-avs/README.md b/sdk/avs/arm-avs/README.md index 73c2aae29485..63a73a5aafa8 100644 --- a/sdk/avs/arm-avs/README.md +++ b/sdk/avs/arm-avs/README.md @@ -1,90 +1,100 @@ ## Azure AvsClient SDK for JavaScript -This package contains an isomorphic SDK for AvsClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AvsClient. ### 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-avs` 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-avs +npm install --save @azure/arm-avs @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { AvsClient, AvsModels, AvsMappers } from "@azure/arm-avs"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { AvsClient } = require("@azure/arm-avs"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AvsClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new AvsClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-avs sample - - + diff --git a/sdk/avs/arm-avs/package.json b/sdk/avs/arm-avs/package.json index 521973d8e7d5..9c5754bc7f3c 100644 --- a/sdk/avs/arm-avs/package.json +++ b/sdk/avs/arm-avs/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-avs", "author": "Microsoft Corporation", "description": "AvsClient 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/avsClient.js", "types": "./esm/avsClient.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/avs/arm-avs/src/avsClient.ts b/sdk/avs/arm-avs/src/avsClient.ts index ddc844d84920..3b2edc265a44 100644 --- a/sdk/avs/arm-avs/src/avsClient.ts +++ b/sdk/avs/arm-avs/src/avsClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -26,11 +27,16 @@ class AvsClient extends AvsClientContext { /** * Initializes a new instance of the AvsClient 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.AvsClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AvsClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.locations = new operations.Locations(this); diff --git a/sdk/avs/arm-avs/src/avsClientContext.ts b/sdk/avs/arm-avs/src/avsClientContext.ts index 3acb23a12a89..03dceb2252d3 100644 --- a/sdk/avs/arm-avs/src/avsClientContext.ts +++ b/sdk/avs/arm-avs/src/avsClientContext.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-avs"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class AvsClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the AvsClient 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.AvsClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AvsClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/azurestack/arm-azurestack/README.md b/sdk/azurestack/arm-azurestack/README.md index 65e5624b65d3..2ccdfc94ebd0 100644 --- a/sdk/azurestack/arm-azurestack/README.md +++ b/sdk/azurestack/arm-azurestack/README.md @@ -1,90 +1,100 @@ ## Azure AzureStackManagementClient SDK for JavaScript -This package contains an isomorphic SDK for AzureStackManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AzureStackManagementClient. ### 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-azurestack` 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-azurestack +npm install --save @azure/arm-azurestack @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { AzureStackManagementClient, AzureStackManagementModels, AzureStackManagementMappers } from "@azure/arm-azurestack"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { AzureStackManagementClient } = require("@azure/arm-azurestack"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AzureStackManagementClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new AzureStackManagementClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-azurestack sample - - + diff --git a/sdk/azurestack/arm-azurestack/package.json b/sdk/azurestack/arm-azurestack/package.json index 10036d2a7aec..8e8e7384f0d9 100644 --- a/sdk/azurestack/arm-azurestack/package.json +++ b/sdk/azurestack/arm-azurestack/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-azurestack", "author": "Microsoft Corporation", "description": "AzureStackManagementClient 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/azureStackManagementClient.js", "types": "./esm/azureStackManagementClient.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/azurestack/arm-azurestack/src/azureStackManagementClient.ts b/sdk/azurestack/arm-azurestack/src/azureStackManagementClient.ts index 04f21ebf7bfd..1e8337f77e14 100644 --- a/sdk/azurestack/arm-azurestack/src/azureStackManagementClient.ts +++ b/sdk/azurestack/arm-azurestack/src/azureStackManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -24,12 +25,17 @@ class AzureStackManagementClient extends AzureStackManagementClientContext { /** * Initializes a new instance of the AzureStackManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials that uniquely identify 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.AzureStackManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureStackManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.products = new operations.Products(this); diff --git a/sdk/azurestack/arm-azurestack/src/azureStackManagementClientContext.ts b/sdk/azurestack/arm-azurestack/src/azureStackManagementClientContext.ts index 1af43d53f712..156bc37d3bc5 100644 --- a/sdk/azurestack/arm-azurestack/src/azureStackManagementClientContext.ts +++ b/sdk/azurestack/arm-azurestack/src/azureStackManagementClientContext.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-azurestack"; -const packageVersion = "2.0.0"; +const packageVersion = "2.1.0"; export class AzureStackManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the AzureStackManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials that uniquely identify 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.AzureStackManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureStackManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/azurestackhci/arm-azurestackhci/README.md b/sdk/azurestackhci/arm-azurestackhci/README.md index 54ed8d33c65a..13116bde073e 100644 --- a/sdk/azurestackhci/arm-azurestackhci/README.md +++ b/sdk/azurestackhci/arm-azurestackhci/README.md @@ -1,90 +1,100 @@ ## Azure AzureStackHCIClient SDK for JavaScript -This package contains an isomorphic SDK for AzureStackHCIClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AzureStackHCIClient. ### 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-azurestackhci` 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-azurestackhci +npm install --save @azure/arm-azurestackhci @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { AzureStackHCIClient, AzureStackHCIModels, AzureStackHCIMappers } from "@azure/arm-azurestackhci"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { AzureStackHCIClient } = require("@azure/arm-azurestackhci"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AzureStackHCIClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new AzureStackHCIClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-azurestackhci sample - - + diff --git a/sdk/azurestackhci/arm-azurestackhci/package.json b/sdk/azurestackhci/arm-azurestackhci/package.json index 95df5ac728c2..1406e3a30a9a 100644 --- a/sdk/azurestackhci/arm-azurestackhci/package.json +++ b/sdk/azurestackhci/arm-azurestackhci/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-azurestackhci", "author": "Microsoft Corporation", "description": "AzureStackHCIClient 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/azureStackHCIClient.js", "types": "./esm/azureStackHCIClient.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/azurestackhci/arm-azurestackhci/src/azureStackHCIClient.ts b/sdk/azurestackhci/arm-azurestackhci/src/azureStackHCIClient.ts index 1d411dcbd664..d4f586397e73 100644 --- a/sdk/azurestackhci/arm-azurestackhci/src/azureStackHCIClient.ts +++ b/sdk/azurestackhci/arm-azurestackhci/src/azureStackHCIClient.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 AzureStackHCIClient extends AzureStackHCIClientContext { /** * Initializes a new instance of the AzureStackHCIClient 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.AzureStackHCIClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureStackHCIClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.clusters = new operations.Clusters(this); diff --git a/sdk/azurestackhci/arm-azurestackhci/src/azureStackHCIClientContext.ts b/sdk/azurestackhci/arm-azurestackhci/src/azureStackHCIClientContext.ts index b820335844ca..6a541775ad3f 100644 --- a/sdk/azurestackhci/arm-azurestackhci/src/azureStackHCIClientContext.ts +++ b/sdk/azurestackhci/arm-azurestackhci/src/azureStackHCIClientContext.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-azurestackhci"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class AzureStackHCIClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the AzureStackHCIClient 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.AzureStackHCIClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureStackHCIClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/batch/arm-batch/README.md b/sdk/batch/arm-batch/README.md index 9347522bf353..7b0d748b036c 100644 --- a/sdk/batch/arm-batch/README.md +++ b/sdk/batch/arm-batch/README.md @@ -1,94 +1,103 @@ ## Azure BatchManagementClient SDK for JavaScript -This package contains an isomorphic SDK for BatchManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for BatchManagementClient. ### 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-batch` 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-batch +npm install --save @azure/arm-batch @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 batchAccount 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 batchAccount 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 { BatchManagementClient, BatchManagementModels, BatchManagementMappers } from "@azure/arm-batch"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { BatchManagementClient } = require("@azure/arm-batch"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new BatchManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const accountName = "testaccountName"; - client.batchAccount.get(resourceGroupName, accountName).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 BatchManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const accountName = "testaccountName"; +client.batchAccount.get(resourceGroupName, accountName).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 batchAccount as an example written in JavaScript. +#### browser - Authentication, client creation, and get batchAccount 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-batch 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/sdk/README.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/batch/arm-batch/README.png) diff --git a/sdk/batch/arm-batch/package.json b/sdk/batch/arm-batch/package.json index de26495de767..25147b040606 100644 --- a/sdk/batch/arm-batch/package.json +++ b/sdk/batch/arm-batch/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-batch", "author": "Microsoft Corporation", "description": "BatchManagementClient 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": "^2.0.0" }, "keywords": [ @@ -31,7 +32,7 @@ "rollup-plugin-sourcemaps": "^0.4.2", "esm": "^3.2.25", "ts-node": "^8.3.0", - "typescript": "~3.9.3", + "typescript": "^3.6.0", "uglify-js": "^3.4.9" }, "homepage": "https://github.com/Azure/azure-sdk-for-js", diff --git a/sdk/batch/arm-batch/src/batchManagementClient.ts b/sdk/batch/arm-batch/src/batchManagementClient.ts index e5c88e5186c8..f59a410fc6ff 100644 --- a/sdk/batch/arm-batch/src/batchManagementClient.ts +++ b/sdk/batch/arm-batch/src/batchManagementClient.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"; @@ -29,12 +30,17 @@ class BatchManagementClient extends BatchManagementClientContext { /** * Initializes a new instance of the BatchManagementClient 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. This is a GUID-formatted string (e.g. * 00000000-0000-0000-0000-000000000000) * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.BatchManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.BatchManagementClientOptions) { super(credentials, subscriptionId, options); this.batchAccount = new operations.BatchAccountOperations(this); this.applicationPackage = new operations.ApplicationPackageOperations(this); diff --git a/sdk/batch/arm-batch/src/batchManagementClientContext.ts b/sdk/batch/arm-batch/src/batchManagementClientContext.ts index 239857a63782..c24d567fca56 100644 --- a/sdk/batch/arm-batch/src/batchManagementClientContext.ts +++ b/sdk/batch/arm-batch/src/batchManagementClientContext.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-batch"; -const packageVersion = "5.0.0"; +const packageVersion = "5.1.0"; export class BatchManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the BatchManagementClient 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. This is a GUID-formatted string (e.g. * 00000000-0000-0000-0000-000000000000) * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.BatchManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.BatchManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/batchai/arm-batchai/README.md b/sdk/batchai/arm-batchai/README.md index ce22680e07c2..8347ce03ac77 100644 --- a/sdk/batchai/arm-batchai/README.md +++ b/sdk/batchai/arm-batchai/README.md @@ -1,89 +1,100 @@ ## Azure BatchAIManagementClient SDK for JavaScript -This package contains an isomorphic SDK for BatchAIManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for BatchAIManagementClient. ### 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-batchai +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-batchai` 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-batchai @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -``` -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```ts -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { BatchAIManagementClient, BatchAIManagementModels, BatchAIManagementMappers } from "@azure/arm-batchai"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { BatchAIManagementClient } = require("@azure/arm-batchai"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new BatchAIManagementClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new BatchAIManagementClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -``` -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-batchai sample - - + @@ -95,5 +106,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fbatchai%2Farm-batchai%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/batchai/arm-batchai/README.png) diff --git a/sdk/batchai/arm-batchai/package.json b/sdk/batchai/arm-batchai/package.json index 89788a2a1fff..e33f70db0f1b 100644 --- a/sdk/batchai/arm-batchai/package.json +++ b/sdk/batchai/arm-batchai/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-batchai", "author": "Microsoft Corporation", "description": "BatchAIManagementClient Library with typescript type definitions for node.js and browser.", - "version": "2.1.0", + "version": "2.2.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.1.0", - "@azure/ms-rest-js": "^1.1.0", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/batchAIManagementClient.js", "types": "./esm/batchAIManagementClient.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/batchai/arm-batchai/src/batchAIManagementClient.ts b/sdk/batchai/arm-batchai/src/batchAIManagementClient.ts index c9af5d391f4d..aa440f6ece90 100644 --- a/sdk/batchai/arm-batchai/src/batchAIManagementClient.ts +++ b/sdk/batchai/arm-batchai/src/batchAIManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -27,11 +28,16 @@ class BatchAIManagementClient extends BatchAIManagementClientContext { /** * Initializes a new instance of the BatchAIManagementClient 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 subscriptionID for the Azure user. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.BatchAIManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.BatchAIManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.usages = new operations.Usages(this); diff --git a/sdk/batchai/arm-batchai/src/batchAIManagementClientContext.ts b/sdk/batchai/arm-batchai/src/batchAIManagementClientContext.ts index ceeed0225f70..4631f2020a19 100644 --- a/sdk/batchai/arm-batchai/src/batchAIManagementClientContext.ts +++ b/sdk/batchai/arm-batchai/src/batchAIManagementClientContext.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-batchai"; -const packageVersion = "0.1.0"; +const packageVersion = "2.2.0"; export class BatchAIManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the BatchAIManagementClient 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 subscriptionID for the Azure user. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.BatchAIManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.BatchAIManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/billing/arm-billing/README.md b/sdk/billing/arm-billing/README.md index cd8267dc6804..1dcfe1a033a9 100644 --- a/sdk/billing/arm-billing/README.md +++ b/sdk/billing/arm-billing/README.md @@ -1,96 +1,101 @@ ## Azure BillingManagementClient SDK for JavaScript -This package contains an isomorphic SDK for BillingManagementClient. - -For more information about Billing: -* [Azure documentation](https://docs.microsoft.com/azure/cost-management-billing/) -* [SDK reference documentation](https://docs.microsoft.com/javascript/api/overview/azure/billing?view=azure-node-latest) +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for BillingManagementClient. ### 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. + +### Prerequisites + +You must have an [Azure subscription](https://azure.microsoft.com/free/). -### How to Install +### How to install +To use this SDK in your project, you will need to install two packages. +- `@azure/arm-billing` 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-billing +npm install --save @azure/arm-billing @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 billingAccounts 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 billingAccounts 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 { BillingManagementClient, BillingManagementModels, BillingManagementMappers } from "@azure/arm-billing"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { BillingManagementClient } = require("@azure/arm-billing"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new BillingManagementClient(creds, subscriptionId); - const expand = "testexpand"; - client.billingAccounts.list(expand).then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new BillingManagementClient(creds, subscriptionId); +const expand = "testexpand"; +client.billingAccounts.list(expand).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list billingAccounts as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list billingAccounts as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-billing sample - - + diff --git a/sdk/billing/arm-billing/package.json b/sdk/billing/arm-billing/package.json index 2c12635400d2..60c50b6e29f5 100644 --- a/sdk/billing/arm-billing/package.json +++ b/sdk/billing/arm-billing/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-billing", "author": "Microsoft Corporation", "description": "BillingManagementClient Library with typescript type definitions for node.js and browser.", - "version": "3.0.0", + "version": "3.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/billingManagementClient.js", "types": "./esm/billingManagementClient.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/billing/arm-billing/src/billingManagementClient.ts b/sdk/billing/arm-billing/src/billingManagementClient.ts index 2ff7dd105b67..a0d1edb23aad 100644 --- a/sdk/billing/arm-billing/src/billingManagementClient.ts +++ b/sdk/billing/arm-billing/src/billingManagementClient.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"; @@ -40,11 +41,16 @@ class BillingManagementClient extends BillingManagementClientContext { /** * Initializes a new instance of the BillingManagementClient 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 that uniquely identifies an Azure subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.BillingManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.BillingManagementClientOptions) { super(credentials, subscriptionId, options); this.billingAccounts = new operations.BillingAccounts(this); this.address = new operations.Address(this); diff --git a/sdk/billing/arm-billing/src/billingManagementClientContext.ts b/sdk/billing/arm-billing/src/billingManagementClientContext.ts index 66679df82359..224c429cd9b4 100644 --- a/sdk/billing/arm-billing/src/billingManagementClientContext.ts +++ b/sdk/billing/arm-billing/src/billingManagementClientContext.ts @@ -10,22 +10,28 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-billing"; -const packageVersion = "3.0.0"; +const packageVersion = "3.1.0"; export class BillingManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; /** * Initializes a new instance of the BillingManagementClient 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 that uniquely identifies an Azure subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.BillingManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.BillingManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/botservice/arm-botservice/README.md b/sdk/botservice/arm-botservice/README.md index 100ad8188bdd..0ee386505106 100644 --- a/sdk/botservice/arm-botservice/README.md +++ b/sdk/botservice/arm-botservice/README.md @@ -1,94 +1,103 @@ ## Azure AzureBotService SDK for JavaScript -This package contains an isomorphic SDK for AzureBotService. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AzureBotService. ### 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-botservice` 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-botservice +npm install --save @azure/arm-botservice @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 bots 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 bots 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 { AzureBotService, AzureBotServiceModels, AzureBotServiceMappers } from "@azure/arm-botservice"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { AzureBotService } = require("@azure/arm-botservice"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AzureBotService(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const resourceName = "testresourceName"; - client.bots.get(resourceGroupName, resourceName).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 AzureBotService(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const resourceName = "testresourceName"; +client.bots.get(resourceGroupName, resourceName).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 bots as an example written in JavaScript. +#### browser - Authentication, client creation, and get bots 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-botservice sample - - + diff --git a/sdk/botservice/arm-botservice/package.json b/sdk/botservice/arm-botservice/package.json index eb0922905502..e68418ca9547 100644 --- a/sdk/botservice/arm-botservice/package.json +++ b/sdk/botservice/arm-botservice/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-botservice", "author": "Microsoft Corporation", "description": "AzureBotService 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/azureBotService.js", "types": "./esm/azureBotService.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/botservice/arm-botservice/src/azureBotService.ts b/sdk/botservice/arm-botservice/src/azureBotService.ts index f2e3696d217a..771e3e36fec4 100644 --- a/sdk/botservice/arm-botservice/src/azureBotService.ts +++ b/sdk/botservice/arm-botservice/src/azureBotService.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"; @@ -25,11 +26,16 @@ class AzureBotService extends AzureBotServiceContext { /** * Initializes a new instance of the AzureBotService class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Azure Subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.AzureBotServiceOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureBotServiceOptions) { super(credentials, subscriptionId, options); this.bots = new operations.Bots(this); this.channels = new operations.Channels(this); diff --git a/sdk/botservice/arm-botservice/src/azureBotServiceContext.ts b/sdk/botservice/arm-botservice/src/azureBotServiceContext.ts index ffc9d3c8d4f9..3261b8039599 100644 --- a/sdk/botservice/arm-botservice/src/azureBotServiceContext.ts +++ b/sdk/botservice/arm-botservice/src/azureBotServiceContext.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-botservice"; -const packageVersion = "2.0.0"; +const packageVersion = "2.1.0"; export class AzureBotServiceContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the AzureBotService class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Azure Subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.AzureBotServiceOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureBotServiceOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/cdn/arm-cdn/README.md b/sdk/cdn/arm-cdn/README.md index 403572708c34..52e45367f756 100644 --- a/sdk/cdn/arm-cdn/README.md +++ b/sdk/cdn/arm-cdn/README.md @@ -1,90 +1,100 @@ ## Azure CdnManagementClient SDK for JavaScript -This package contains an isomorphic SDK for CdnManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for CdnManagementClient. ### 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-cdn` 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-cdn +npm install --save @azure/arm-cdn @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 profiles 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 profiles 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 { CdnManagementClient, CdnManagementModels, CdnManagementMappers } from "@azure/arm-cdn"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { CdnManagementClient } = require("@azure/arm-cdn"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new CdnManagementClient(creds, subscriptionId); - client.profiles.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new CdnManagementClient(creds, subscriptionId); + +client.profiles.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list profiles as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list profiles as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-cdn sample - - + diff --git a/sdk/cdn/arm-cdn/package.json b/sdk/cdn/arm-cdn/package.json index cb200703ce7e..d9a34566a5e9 100644 --- a/sdk/cdn/arm-cdn/package.json +++ b/sdk/cdn/arm-cdn/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-cdn", "author": "Microsoft Corporation", "description": "CdnManagementClient Library with typescript type definitions for node.js and browser.", - "version": "5.2.0", + "version": "5.3.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/cdnManagementClient.js", "types": "./esm/cdnManagementClient.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/cdn/arm-cdn/src/cdnManagementClient.ts b/sdk/cdn/arm-cdn/src/cdnManagementClient.ts index d2eb2d60b2d4..bb34c2fcd2af 100644 --- a/sdk/cdn/arm-cdn/src/cdnManagementClient.ts +++ b/sdk/cdn/arm-cdn/src/cdnManagementClient.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 CdnManagementClient extends CdnManagementClientContext { /** * Initializes a new instance of the CdnManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Azure Subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.CdnManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.CdnManagementClientOptions) { super(credentials, subscriptionId, options); this.profiles = new operations.Profiles(this); this.endpoints = new operations.Endpoints(this); diff --git a/sdk/cdn/arm-cdn/src/cdnManagementClientContext.ts b/sdk/cdn/arm-cdn/src/cdnManagementClientContext.ts index 9caddabff417..bca3d4ca420a 100644 --- a/sdk/cdn/arm-cdn/src/cdnManagementClientContext.ts +++ b/sdk/cdn/arm-cdn/src/cdnManagementClientContext.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-cdn"; -const packageVersion = "5.2.0"; +const packageVersion = "5.3.0"; export class CdnManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the CdnManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Azure Subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.CdnManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.CdnManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/changeanalysis/arm-changeanalysis/README.md b/sdk/changeanalysis/arm-changeanalysis/README.md index 166d262ef482..ee3668c3ea89 100644 --- a/sdk/changeanalysis/arm-changeanalysis/README.md +++ b/sdk/changeanalysis/arm-changeanalysis/README.md @@ -1,91 +1,101 @@ ## Azure AzureChangeAnalysisManagementClient SDK for JavaScript -This package contains an isomorphic SDK for AzureChangeAnalysisManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AzureChangeAnalysisManagementClient. ### 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-changeanalysis` 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-changeanalysis +npm install --save @azure/arm-changeanalysis @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -While the below sample uses the interactive login, other authentication options can be found in the [README.md file of @azure/ms-rest-nodeauth](https://www.npmjs.com/package/@azure/ms-rest-nodeauth) package -```typescript -const msRestNodeAuth = require("@azure/ms-rest-nodeauth"); +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); const { AzureChangeAnalysisManagementClient } = require("@azure/arm-changeanalysis"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AzureChangeAnalysisManagementClient(creds, subscriptionId); - const skipToken = "testskipToken"; - client.operations.list(skipToken).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 AzureChangeAnalysisManagementClient(creds, subscriptionId); +const skipToken = "testskipToken"; +client.operations.list(skipToken).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-changeanalysis sample - - + diff --git a/sdk/changeanalysis/arm-changeanalysis/package.json b/sdk/changeanalysis/arm-changeanalysis/package.json index 69961f1bdfaf..9a81486953c0 100644 --- a/sdk/changeanalysis/arm-changeanalysis/package.json +++ b/sdk/changeanalysis/arm-changeanalysis/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-changeanalysis", "author": "Microsoft Corporation", "description": "AzureChangeAnalysisManagementClient 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/azureChangeAnalysisManagementClient.js", "types": "./esm/azureChangeAnalysisManagementClient.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/changeanalysis/arm-changeanalysis/src/azureChangeAnalysisManagementClient.ts b/sdk/changeanalysis/arm-changeanalysis/src/azureChangeAnalysisManagementClient.ts index 342ec995b7e8..e3b4a848a93c 100644 --- a/sdk/changeanalysis/arm-changeanalysis/src/azureChangeAnalysisManagementClient.ts +++ b/sdk/changeanalysis/arm-changeanalysis/src/azureChangeAnalysisManagementClient.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"; @@ -22,11 +23,16 @@ class AzureChangeAnalysisManagementClient extends AzureChangeAnalysisManagementC /** * Initializes a new instance of the AzureChangeAnalysisManagementClient 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.AzureChangeAnalysisManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureChangeAnalysisManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.resourceChanges = new operations.ResourceChanges(this); diff --git a/sdk/changeanalysis/arm-changeanalysis/src/azureChangeAnalysisManagementClientContext.ts b/sdk/changeanalysis/arm-changeanalysis/src/azureChangeAnalysisManagementClientContext.ts index 2b91db73d014..ad921482493d 100644 --- a/sdk/changeanalysis/arm-changeanalysis/src/azureChangeAnalysisManagementClientContext.ts +++ b/sdk/changeanalysis/arm-changeanalysis/src/azureChangeAnalysisManagementClientContext.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-changeanalysis"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class AzureChangeAnalysisManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the AzureChangeAnalysisManagementClient 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.AzureChangeAnalysisManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureChangeAnalysisManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/README.md b/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/README.md index e719b827a97c..52b700638226 100644 --- a/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/README.md +++ b/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/README.md @@ -1,100 +1,109 @@ ## Azure UsageManagementClient SDK for JavaScript -This package contains an isomorphic SDK for UsageManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for UsageManagementClient. ### 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-commerce-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-commerce-profile-2020-09-01-hybrid +npm install --save @azure/arm-commerce-profile-2020-09-01-hybrid @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list usageAggregates 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 usageAggregates 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 { UsageManagementClient, UsageManagementModels, UsageManagementMappers } from "@azure/arm-commerce-profile-2020-09-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { UsageManagementClient } = require("@azure/arm-commerce-profile-2020-09-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new UsageManagementClient(creds, subscriptionId); - const reportedStartTime = new Date().toISOString(); - const reportedEndTime = new Date().toISOString(); - const showDetails = true; - const aggregationGranularity = "Daily"; - const continuationToken = "testcontinuationToken"; - client.usageAggregates.list(reportedStartTime, reportedEndTime, showDetails, aggregationGranularity, continuationToken).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 UsageManagementClient(creds, subscriptionId); +const reportedStartTime = new Date().toISOString(); +const reportedEndTime = new Date().toISOString(); +const showDetails = true; +const aggregationGranularity = "Daily"; +const continuationToken = "testcontinuationToken"; +client.usageAggregates.list(reportedStartTime, reportedEndTime, showDetails, aggregationGranularity, continuationToken).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 usageAggregates as an example written in JavaScript. +#### browser - Authentication, client creation, and list usageAggregates 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-commerce-profile-2020-09-01-hybrid sample - - + diff --git a/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/package.json b/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/package.json index 10e0e9e4a945..5dc45d4a25f4 100644 --- a/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/package.json +++ b/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-commerce-profile-2020-09-01-hybrid", "author": "Microsoft Corporation", "description": "UsageManagementClient 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/usageManagementClient.js", "types": "./esm/usageManagementClient.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/commerce/arm-commerce-profile-2020-09-01-hybrid/src/usageManagementClient.ts b/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/src/usageManagementClient.ts index 14140e6bff74..dcd1922bb0cd 100644 --- a/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/src/usageManagementClient.ts +++ b/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/src/usageManagementClient.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 UsageManagementClient extends UsageManagementClientContext { /** * Initializes a new instance of the UsageManagementClient 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 It uniquely identifies 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.UsageManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.UsageManagementClientOptions) { super(credentials, subscriptionId, options); this.usageAggregates = new operations.UsageAggregates(this); this.rateCard = new operations.RateCard(this); diff --git a/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/src/usageManagementClientContext.ts b/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/src/usageManagementClientContext.ts index f1b3432104d8..3ce8b7086378 100644 --- a/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/src/usageManagementClientContext.ts +++ b/sdk/commerce/arm-commerce-profile-2020-09-01-hybrid/src/usageManagementClientContext.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-commerce-profile-2020-09-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class UsageManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the UsageManagementClient 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 It uniquely identifies 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.UsageManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.UsageManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/commerce/arm-commerce/README.md b/sdk/commerce/arm-commerce/README.md index 328e15132f6a..1179d4d83ce4 100644 --- a/sdk/commerce/arm-commerce/README.md +++ b/sdk/commerce/arm-commerce/README.md @@ -1,99 +1,109 @@ ## Azure UsageManagementClient SDK for JavaScript -This package contains an isomorphic SDK for UsageManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for UsageManagementClient. ### 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-commerce` 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-commerce +npm install --save @azure/arm-commerce @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 usageAggregates as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -```bash -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list usageAggregates 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 { UsageManagementClient, UsageManagementModels, UsageManagementMappers } from "@azure/arm-commerce"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { UsageManagementClient } = require("@azure/arm-commerce"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new UsageManagementClient(creds, subscriptionId); - const reportedStartTime = new Date().toISOString(); - const reportedEndTime = new Date().toISOString(); - const showDetails = true; - const aggregationGranularity = "Daily"; - const continuationToken = "testcontinuationToken"; - client.usageAggregates.list(reportedStartTime, reportedEndTime, showDetails, aggregationGranularity, continuationToken).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 UsageManagementClient(creds, subscriptionId); +const reportedStartTime = new Date().toISOString(); +const reportedEndTime = new Date().toISOString(); +const showDetails = true; +const aggregationGranularity = "Daily"; +const continuationToken = "testcontinuationToken"; +client.usageAggregates.list(reportedStartTime, reportedEndTime, showDetails, aggregationGranularity, continuationToken).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 usageAggregates as an example written in JavaScript. +#### browser - Authentication, client creation, and list usageAggregates 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-commerce sample - - + @@ -105,5 +115,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%2Fcommerce%2Farm-commerce%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/commerce/arm-commerce/README.png) diff --git a/sdk/commerce/arm-commerce/package.json b/sdk/commerce/arm-commerce/package.json index d626b9efb1f8..286ef12b9e29 100644 --- a/sdk/commerce/arm-commerce/package.json +++ b/sdk/commerce/arm-commerce/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-commerce", "author": "Microsoft Corporation", "description": "UsageManagementClient Library with typescript type definitions for node.js and browser.", - "version": "2.1.1", + "version": "2.2.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.2.0", - "@azure/ms-rest-js": "^1.2.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/usageManagementClient.js", "types": "./esm/usageManagementClient.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/commerce/arm-commerce/src/usageManagementClient.ts b/sdk/commerce/arm-commerce/src/usageManagementClient.ts index 14140e6bff74..dcd1922bb0cd 100644 --- a/sdk/commerce/arm-commerce/src/usageManagementClient.ts +++ b/sdk/commerce/arm-commerce/src/usageManagementClient.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 UsageManagementClient extends UsageManagementClientContext { /** * Initializes a new instance of the UsageManagementClient 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 It uniquely identifies 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.UsageManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.UsageManagementClientOptions) { super(credentials, subscriptionId, options); this.usageAggregates = new operations.UsageAggregates(this); this.rateCard = new operations.RateCard(this); diff --git a/sdk/commerce/arm-commerce/src/usageManagementClientContext.ts b/sdk/commerce/arm-commerce/src/usageManagementClientContext.ts index f2995a21ee7e..5e9e2eca1fbc 100644 --- a/sdk/commerce/arm-commerce/src/usageManagementClientContext.ts +++ b/sdk/commerce/arm-commerce/src/usageManagementClientContext.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-commerce"; -const packageVersion = "2.1.1"; +const packageVersion = "2.2.0"; export class UsageManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the UsageManagementClient 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 It uniquely identifies 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.UsageManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.UsageManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/communication/arm-communication/README.md b/sdk/communication/arm-communication/README.md index 6de5fb8a12ba..15ddebb729bf 100644 --- a/sdk/communication/arm-communication/README.md +++ b/sdk/communication/arm-communication/README.md @@ -1,89 +1,100 @@ ## Azure CommunicationServiceManagementClient SDK for JavaScript -This package contains an isomorphic SDK for CommunicationServiceManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for CommunicationServiceManagementClient. ### 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-communication` 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-communication +npm install --save @azure/arm-communication @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -While the below sample uses the interactive login, other authentication options can be found in the [README.md file of @azure/ms-rest-nodeauth](https://www.npmjs.com/package/@azure/ms-rest-nodeauth) package -```typescript -const msRestNodeAuth = require("@azure/ms-rest-nodeauth"); +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); const { CommunicationServiceManagementClient } = require("@azure/arm-communication"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new CommunicationServiceManagementClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new CommunicationServiceManagementClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-communication sample - - + diff --git a/sdk/communication/arm-communication/package.json b/sdk/communication/arm-communication/package.json index e2098d0bff19..fd787d7dbae8 100644 --- a/sdk/communication/arm-communication/package.json +++ b/sdk/communication/arm-communication/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-communication", "author": "Microsoft Corporation", "description": "CommunicationServiceManagementClient 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/communicationServiceManagementClient.js", "types": "./esm/communicationServiceManagementClient.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/communication/arm-communication/src/communicationServiceManagementClient.ts b/sdk/communication/arm-communication/src/communicationServiceManagementClient.ts index 4e5cad89ba86..fc437ea41185 100644 --- a/sdk/communication/arm-communication/src/communicationServiceManagementClient.ts +++ b/sdk/communication/arm-communication/src/communicationServiceManagementClient.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"; @@ -22,11 +23,16 @@ class CommunicationServiceManagementClient extends CommunicationServiceManagemen /** * Initializes a new instance of the CommunicationServiceManagementClient 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.CommunicationServiceManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.CommunicationServiceManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.communicationService = new operations.CommunicationService(this); diff --git a/sdk/communication/arm-communication/src/communicationServiceManagementClientContext.ts b/sdk/communication/arm-communication/src/communicationServiceManagementClientContext.ts index ffb1a34ea68c..ff2a71850cb3 100644 --- a/sdk/communication/arm-communication/src/communicationServiceManagementClientContext.ts +++ b/sdk/communication/arm-communication/src/communicationServiceManagementClientContext.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-communication"; -const packageVersion = "2.0.0"; +const packageVersion = "2.1.0"; export class CommunicationServiceManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the CommunicationServiceManagementClient 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.CommunicationServiceManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.CommunicationServiceManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/compute/arm-compute-profile-2019-03-01-hybrid/README.md b/sdk/compute/arm-compute-profile-2019-03-01-hybrid/README.md index c9a2b4280963..a826f14d137a 100644 --- a/sdk/compute/arm-compute-profile-2019-03-01-hybrid/README.md +++ b/sdk/compute/arm-compute-profile-2019-03-01-hybrid/README.md @@ -1,89 +1,100 @@ ## Azure ComputeManagementClient SDK for JavaScript -This package contains an isomorphic SDK for ComputeManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ComputeManagementClient. ### 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-compute-profile-2019-03-01-hybrid` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/arm-compute-profile-2019-03-01-hybrid +npm install --save @azure/arm-compute-profile-2019-03-01-hybrid @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -```bash -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { ComputeManagementClient, ComputeManagementModels, ComputeManagementMappers } from "@azure/arm-compute-profile-2019-03-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { ComputeManagementClient } = require("@azure/arm-compute-profile-2019-03-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ComputeManagementClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new ComputeManagementClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-compute-profile-2019-03-01-hybrid sample - - + @@ -95,5 +106,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcompute%2Farm-compute-profile-2019-03-01-hybrid%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/compute/arm-compute-profile-2019-03-01-hybrid/README.png) diff --git a/sdk/compute/arm-compute-profile-2019-03-01-hybrid/package.json b/sdk/compute/arm-compute-profile-2019-03-01-hybrid/package.json index 2ad22338fb2d..196ec72599b6 100644 --- a/sdk/compute/arm-compute-profile-2019-03-01-hybrid/package.json +++ b/sdk/compute/arm-compute-profile-2019-03-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-compute-profile-2019-03-01-hybrid", "author": "Microsoft Corporation", "description": "ComputeManagementClient 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/computeManagementClient.js", "types": "./esm/computeManagementClient.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/compute/arm-compute-profile-2019-03-01-hybrid/src/computeManagementClient.ts b/sdk/compute/arm-compute-profile-2019-03-01-hybrid/src/computeManagementClient.ts index 7717ff363ef5..70faef5380b9 100644 --- a/sdk/compute/arm-compute-profile-2019-03-01-hybrid/src/computeManagementClient.ts +++ b/sdk/compute/arm-compute-profile-2019-03-01-hybrid/src/computeManagementClient.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"; @@ -36,12 +37,17 @@ class ComputeManagementClient extends ComputeManagementClientContext { /** * Initializes a new instance of the ComputeManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials 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.ComputeManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ComputeManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.availabilitySets = new operations.AvailabilitySets(this); diff --git a/sdk/compute/arm-compute-profile-2019-03-01-hybrid/src/computeManagementClientContext.ts b/sdk/compute/arm-compute-profile-2019-03-01-hybrid/src/computeManagementClientContext.ts index cb5d78ac19ed..a730670ee6b3 100644 --- a/sdk/compute/arm-compute-profile-2019-03-01-hybrid/src/computeManagementClientContext.ts +++ b/sdk/compute/arm-compute-profile-2019-03-01-hybrid/src/computeManagementClientContext.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-compute-profile-2019-03-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class ComputeManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; /** * Initializes a new instance of the ComputeManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials 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.ComputeManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ComputeManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/compute/arm-compute-profile-2020-09-01-hybrid/README.md b/sdk/compute/arm-compute-profile-2020-09-01-hybrid/README.md index 0e725eab0838..7369c32125c9 100644 --- a/sdk/compute/arm-compute-profile-2020-09-01-hybrid/README.md +++ b/sdk/compute/arm-compute-profile-2020-09-01-hybrid/README.md @@ -1,90 +1,100 @@ ## Azure ComputeManagementClient SDK for JavaScript -This package contains an isomorphic SDK for ComputeManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ComputeManagementClient. ### 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-compute-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-compute-profile-2020-09-01-hybrid +npm install --save @azure/arm-compute-profile-2020-09-01-hybrid @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { ComputeManagementClient, ComputeManagementModels, ComputeManagementMappers } from "@azure/arm-compute-profile-2020-09-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { ComputeManagementClient } = require("@azure/arm-compute-profile-2020-09-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ComputeManagementClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new ComputeManagementClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-compute-profile-2020-09-01-hybrid sample - - + diff --git a/sdk/compute/arm-compute-profile-2020-09-01-hybrid/package.json b/sdk/compute/arm-compute-profile-2020-09-01-hybrid/package.json index 199abcf82637..70f0b176486a 100644 --- a/sdk/compute/arm-compute-profile-2020-09-01-hybrid/package.json +++ b/sdk/compute/arm-compute-profile-2020-09-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-compute-profile-2020-09-01-hybrid", "author": "Microsoft Corporation", "description": "ComputeManagementClient 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/computeManagementClient.js", "types": "./esm/computeManagementClient.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/compute/arm-compute-profile-2020-09-01-hybrid/src/computeManagementClient.ts b/sdk/compute/arm-compute-profile-2020-09-01-hybrid/src/computeManagementClient.ts index 9ae1d6a5cf1f..6ae60a09db8b 100644 --- a/sdk/compute/arm-compute-profile-2020-09-01-hybrid/src/computeManagementClient.ts +++ b/sdk/compute/arm-compute-profile-2020-09-01-hybrid/src/computeManagementClient.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"; @@ -42,12 +43,17 @@ class ComputeManagementClient extends ComputeManagementClientContext { /** * Initializes a new instance of the ComputeManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials 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.ComputeManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ComputeManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.availabilitySets = new operations.AvailabilitySets(this); diff --git a/sdk/compute/arm-compute-profile-2020-09-01-hybrid/src/computeManagementClientContext.ts b/sdk/compute/arm-compute-profile-2020-09-01-hybrid/src/computeManagementClientContext.ts index b85d0e4ded9e..325e1c725f7e 100644 --- a/sdk/compute/arm-compute-profile-2020-09-01-hybrid/src/computeManagementClientContext.ts +++ b/sdk/compute/arm-compute-profile-2020-09-01-hybrid/src/computeManagementClientContext.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-compute-profile-2020-09-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class ComputeManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; /** * Initializes a new instance of the ComputeManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials 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.ComputeManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ComputeManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/confluent/arm-confluent/README.md b/sdk/confluent/arm-confluent/README.md index 9ca2a62fcf35..41008e2f9e0c 100644 --- a/sdk/confluent/arm-confluent/README.md +++ b/sdk/confluent/arm-confluent/README.md @@ -1,89 +1,100 @@ ## Azure ConfluentManagementClient SDK for JavaScript -This package contains an isomorphic SDK for ConfluentManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ConfluentManagementClient. ### 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-confluent` 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-confluent +npm install --save @azure/arm-confluent @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - client creation and list marketplaceAgreements 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 marketplaceAgreements 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 { ConfluentManagementClient } = require("@azure/arm-confluent"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ConfluentManagementClient(creds, subscriptionId); - client.marketplaceAgreements.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new ConfluentManagementClient(creds, subscriptionId); + +client.marketplaceAgreements.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list marketplaceAgreements as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list marketplaceAgreements as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-confluent sample - - + diff --git a/sdk/confluent/arm-confluent/package.json b/sdk/confluent/arm-confluent/package.json index 948efd97df24..c162f30e8f5e 100644 --- a/sdk/confluent/arm-confluent/package.json +++ b/sdk/confluent/arm-confluent/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-confluent", "author": "Microsoft Corporation", "description": "ConfluentManagementClient 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/confluentManagementClient.js", "types": "./esm/confluentManagementClient.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/confluent/arm-confluent/src/confluentManagementClient.ts b/sdk/confluent/arm-confluent/src/confluentManagementClient.ts index 60039d7957d1..fc7af6cbdb46 100644 --- a/sdk/confluent/arm-confluent/src/confluentManagementClient.ts +++ b/sdk/confluent/arm-confluent/src/confluentManagementClient.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"; @@ -22,12 +23,17 @@ class ConfluentManagementClient extends ConfluentManagementClientContext { /** * Initializes a new instance of the ConfluentManagementClient 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 Microsoft Azure subscription id * @param [options] The parameter options */ constructor( - credentials: msRest.ServiceClientCredentials, + credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ConfluentManagementClientOptions ) { diff --git a/sdk/confluent/arm-confluent/src/confluentManagementClientContext.ts b/sdk/confluent/arm-confluent/src/confluentManagementClientContext.ts index 8714f2bdeebd..e40c2e8002a2 100644 --- a/sdk/confluent/arm-confluent/src/confluentManagementClientContext.ts +++ b/sdk/confluent/arm-confluent/src/confluentManagementClientContext.ts @@ -9,24 +9,30 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-confluent"; -const packageVersion = "2.0.0"; +const packageVersion = "2.1.0"; export class ConfluentManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the ConfluentManagementClient 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 Microsoft Azure subscription id * @param [options] The parameter options */ constructor( - credentials: msRest.ServiceClientCredentials, + credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ConfluentManagementClientOptions ) { diff --git a/sdk/consumption/arm-consumption/README.md b/sdk/consumption/arm-consumption/README.md index de366b0db722..f89dec55ae63 100644 --- a/sdk/consumption/arm-consumption/README.md +++ b/sdk/consumption/arm-consumption/README.md @@ -1,70 +1,78 @@ ## Azure ConsumptionManagementClient SDK for JavaScript -This package contains an isomorphic SDK for ConsumptionManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ConsumptionManagementClient. ### 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-consumption` 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-consumption +npm install --save @azure/arm-consumption @azure/identity ``` -### How to use +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. -#### nodejs - client creation and list usageDetails as an example written in TypeScript. +### How to use -##### Install @azure/ms-rest-nodeauth +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list usageDetails 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 { ConsumptionManagementClient } = require("@azure/arm-consumption"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth - .interactiveLogin() - .then((creds) => { - const client = new ConsumptionManagementClient(creds, subscriptionId); - const expand = "testexpand"; - const filter = "testfilter"; - const skiptoken = "testskiptoken"; - const top = 1; - const apply = "testapply"; - client.usageDetails.list(expand, filter, skiptoken, top, apply).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 ConsumptionManagementClient(creds, subscriptionId); +const expand = "testexpand"; +const filter = "testfilter"; +const skiptoken = "testskiptoken"; +const top = 1; +const apply = "testapply"; +client.usageDetails.list(expand, filter, skiptoken, top, apply).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 usageDetails as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list usageDetails 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 @@ -72,40 +80,30 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to @azure/arm-consumption sample - - + diff --git a/sdk/consumption/arm-consumption/package.json b/sdk/consumption/arm-consumption/package.json index 0630b1c7652d..d1928028ae1c 100644 --- a/sdk/consumption/arm-consumption/package.json +++ b/sdk/consumption/arm-consumption/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-consumption", "author": "Microsoft Corporation", "description": "ConsumptionManagementClient Library with typescript type definitions for node.js and browser.", - "version": "7.0.0", + "version": "7.1.0", "dependencies": { - "@azure/ms-rest-azure-js": "^2.0.1", - "@azure/ms-rest-js": "^2.0.4", + "@azure/ms-rest-azure-js": "^2.1.0", + "@azure/ms-rest-js": "^2.2.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.10.0" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/consumptionManagementClient.js", "types": "./esm/consumptionManagementClient.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/consumption/arm-consumption/src/consumptionManagementClient.ts b/sdk/consumption/arm-consumption/src/consumptionManagementClient.ts index b22a01878ab6..d9b9c1705ca0 100644 --- a/sdk/consumption/arm-consumption/src/consumptionManagementClient.ts +++ b/sdk/consumption/arm-consumption/src/consumptionManagementClient.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"; @@ -32,12 +33,17 @@ class ConsumptionManagementClient extends ConsumptionManagementClientContext { /** * Initializes a new instance of the ConsumptionManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Azure Subscription ID. * @param [options] The parameter options */ constructor( - credentials: msRest.ServiceClientCredentials, + credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ConsumptionManagementClientOptions ) { diff --git a/sdk/consumption/arm-consumption/src/consumptionManagementClientContext.ts b/sdk/consumption/arm-consumption/src/consumptionManagementClientContext.ts index 3a780eadfee0..072c5c28af97 100644 --- a/sdk/consumption/arm-consumption/src/consumptionManagementClientContext.ts +++ b/sdk/consumption/arm-consumption/src/consumptionManagementClientContext.ts @@ -9,24 +9,30 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-consumption"; -const packageVersion = "7.0.0"; +const packageVersion = "7.1.0"; export class ConsumptionManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the ConsumptionManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Azure Subscription ID. * @param [options] The parameter options */ constructor( - credentials: msRest.ServiceClientCredentials, + credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ConsumptionManagementClientOptions ) { diff --git a/sdk/containerinstance/arm-containerinstance/README.md b/sdk/containerinstance/arm-containerinstance/README.md index 8dc6a1b42563..3cd6f8bf240c 100644 --- a/sdk/containerinstance/arm-containerinstance/README.md +++ b/sdk/containerinstance/arm-containerinstance/README.md @@ -1,89 +1,100 @@ ## Azure ContainerInstanceManagementClient SDK for JavaScript -This package contains an isomorphic SDK for ContainerInstanceManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ContainerInstanceManagementClient. ### 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-containerinstance` 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-containerinstance +npm install --save @azure/arm-containerinstance @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - client creation and list containerGroups 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 containerGroups 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 { ContainerInstanceManagementClient } = require("@azure/arm-containerinstance"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ContainerInstanceManagementClient(creds, subscriptionId); - client.containerGroups.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new ContainerInstanceManagementClient(creds, subscriptionId); + +client.containerGroups.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list containerGroups as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list containerGroups as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-containerinstance sample - - + diff --git a/sdk/containerinstance/arm-containerinstance/package.json b/sdk/containerinstance/arm-containerinstance/package.json index d838e3794d2d..79fcc23fb81d 100644 --- a/sdk/containerinstance/arm-containerinstance/package.json +++ b/sdk/containerinstance/arm-containerinstance/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-containerinstance", "author": "Microsoft Corporation", "description": "ContainerInstanceManagementClient Library with typescript type definitions for node.js and browser.", - "version": "6.1.0", + "version": "6.2.0", "dependencies": { - "@azure/ms-rest-azure-js": "^2.0.1", - "@azure/ms-rest-js": "^2.0.4", + "@azure/ms-rest-azure-js": "^2.1.0", + "@azure/ms-rest-js": "^2.2.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.10.0" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/containerInstanceManagementClient.js", "types": "./esm/containerInstanceManagementClient.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/containerinstance/arm-containerinstance/src/containerInstanceManagementClient.ts b/sdk/containerinstance/arm-containerinstance/src/containerInstanceManagementClient.ts index 0fb60a54b53e..fd8bb11807b4 100644 --- a/sdk/containerinstance/arm-containerinstance/src/containerInstanceManagementClient.ts +++ b/sdk/containerinstance/arm-containerinstance/src/containerInstanceManagementClient.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 ContainerInstanceManagementClient extends ContainerInstanceManagementClien /** * Initializes a new instance of the ContainerInstanceManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials 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.ContainerInstanceManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ContainerInstanceManagementClientOptions) { super(credentials, subscriptionId, options); this.containerGroups = new operations.ContainerGroups(this); this.operations = new operations.Operations(this); diff --git a/sdk/containerinstance/arm-containerinstance/src/containerInstanceManagementClientContext.ts b/sdk/containerinstance/arm-containerinstance/src/containerInstanceManagementClientContext.ts index c86399f5c7ea..dac70a4356bd 100644 --- a/sdk/containerinstance/arm-containerinstance/src/containerInstanceManagementClientContext.ts +++ b/sdk/containerinstance/arm-containerinstance/src/containerInstanceManagementClientContext.ts @@ -9,24 +9,30 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-containerinstance"; -const packageVersion = "6.1.0"; +const packageVersion = "6.2.0"; export class ContainerInstanceManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the ContainerInstanceManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials 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.ContainerInstanceManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ContainerInstanceManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/containerregistry/arm-containerregistry/README.md b/sdk/containerregistry/arm-containerregistry/README.md index 2afe51005264..f4fd8ab3ba79 100644 --- a/sdk/containerregistry/arm-containerregistry/README.md +++ b/sdk/containerregistry/arm-containerregistry/README.md @@ -1,96 +1,105 @@ ## Azure ContainerRegistryManagementClient SDK for JavaScript -This package contains an isomorphic SDK for ContainerRegistryManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ContainerRegistryManagementClient. ### 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-containerregistry` 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-containerregistry +npm install --save @azure/arm-containerregistry @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 exportPipelines 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 exportPipelines 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 { ContainerRegistryManagementClient, ContainerRegistryManagementModels, ContainerRegistryManagementMappers } from "@azure/arm-containerregistry"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { ContainerRegistryManagementClient } = require("@azure/arm-containerregistry"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ContainerRegistryManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const registryName = "testregistryName"; - const exportPipelineName = "testexportPipelineName"; - client.exportPipelines.get(resourceGroupName, registryName, exportPipelineName).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 ContainerRegistryManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const registryName = "testregistryName"; +const exportPipelineName = "testexportPipelineName"; +client.exportPipelines.get(resourceGroupName, registryName, exportPipelineName).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 exportPipelines as an example written in JavaScript. +#### browser - Authentication, client creation, and get exportPipelines 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-containerregistry sample - - + diff --git a/sdk/containerregistry/arm-containerregistry/package.json b/sdk/containerregistry/arm-containerregistry/package.json index f97ea35d7d71..fb2c5594ce96 100644 --- a/sdk/containerregistry/arm-containerregistry/package.json +++ b/sdk/containerregistry/arm-containerregistry/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-containerregistry", "author": "Microsoft Corporation", "description": "ContainerRegistryManagementClient Library with typescript type definitions for node.js and browser.", - "version": "8.0.0", + "version": "8.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/containerRegistryManagementClient.js", "types": "./esm/containerRegistryManagementClient.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/containerregistry/arm-containerregistry/src/containerRegistryManagementClient.ts b/sdk/containerregistry/arm-containerregistry/src/containerRegistryManagementClient.ts index 19afb901c50b..0a3143427278 100644 --- a/sdk/containerregistry/arm-containerregistry/src/containerRegistryManagementClient.ts +++ b/sdk/containerregistry/arm-containerregistry/src/containerRegistryManagementClient.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"; @@ -34,11 +35,16 @@ class ContainerRegistryManagementClient extends ContainerRegistryManagementClien /** * Initializes a new instance of the ContainerRegistryManagementClient 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 Microsoft Azure subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ContainerRegistryManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ContainerRegistryManagementClientOptions) { super(credentials, subscriptionId, options); this.exportPipelines = new operations.ExportPipelines(this); this.registries = new operations.Registries(this); diff --git a/sdk/containerregistry/arm-containerregistry/src/containerRegistryManagementClientContext.ts b/sdk/containerregistry/arm-containerregistry/src/containerRegistryManagementClientContext.ts index a0016e0583e5..9ad2845a5a15 100644 --- a/sdk/containerregistry/arm-containerregistry/src/containerRegistryManagementClientContext.ts +++ b/sdk/containerregistry/arm-containerregistry/src/containerRegistryManagementClientContext.ts @@ -10,22 +10,28 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-containerregistry"; -const packageVersion = "8.0.0"; +const packageVersion = "8.1.0"; export class ContainerRegistryManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; /** * Initializes a new instance of the ContainerRegistryManagementClient 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 Microsoft Azure subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ContainerRegistryManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ContainerRegistryManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/containerservice/arm-containerservice/README.md b/sdk/containerservice/arm-containerservice/README.md index ba129c1f3b94..5c707f9dbfdc 100644 --- a/sdk/containerservice/arm-containerservice/README.md +++ b/sdk/containerservice/arm-containerservice/README.md @@ -1,89 +1,100 @@ ## Azure ContainerServiceClient SDK for JavaScript -This package contains an isomorphic SDK for ContainerServiceClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for ContainerServiceClient. ### 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-containerservice` 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-containerservice +npm install --save @azure/arm-containerservice @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -While the below sample uses the interactive login, other authentication options can be found in the [README.md file of @azure/ms-rest-nodeauth](https://www.npmjs.com/package/@azure/ms-rest-nodeauth) package -```typescript -const msRestNodeAuth = require("@azure/ms-rest-nodeauth"); +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); const { ContainerServiceClient } = require("@azure/arm-containerservice"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new ContainerServiceClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new ContainerServiceClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-containerservice sample - - + diff --git a/sdk/containerservice/arm-containerservice/package.json b/sdk/containerservice/arm-containerservice/package.json index abdfbf9dae1d..77ccc2090831 100644 --- a/sdk/containerservice/arm-containerservice/package.json +++ b/sdk/containerservice/arm-containerservice/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-containerservice", "author": "Microsoft Corporation", "description": "ContainerServiceClient Library with typescript type definitions for node.js and browser.", - "version": "13.2.0", + "version": "13.3.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/containerServiceClient.js", "types": "./esm/containerServiceClient.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/containerservice/arm-containerservice/src/containerServiceClient.ts b/sdk/containerservice/arm-containerservice/src/containerServiceClient.ts index 6997e3ab5ce7..244f833d630c 100644 --- a/sdk/containerservice/arm-containerservice/src/containerServiceClient.ts +++ b/sdk/containerservice/arm-containerservice/src/containerServiceClient.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"; @@ -26,12 +27,17 @@ class ContainerServiceClient extends ContainerServiceClientContext { /** * Initializes a new instance of the ContainerServiceClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials 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.ContainerServiceClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ContainerServiceClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.managedClusters = new operations.ManagedClusters(this); diff --git a/sdk/containerservice/arm-containerservice/src/containerServiceClientContext.ts b/sdk/containerservice/arm-containerservice/src/containerServiceClientContext.ts index 5e6112ec9cca..931b9efe6aa0 100644 --- a/sdk/containerservice/arm-containerservice/src/containerServiceClientContext.ts +++ b/sdk/containerservice/arm-containerservice/src/containerServiceClientContext.ts @@ -9,24 +9,30 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-containerservice"; -const packageVersion = "13.2.0"; +const packageVersion = "13.3.0"; export class ContainerServiceClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the ContainerServiceClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials 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.ContainerServiceClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ContainerServiceClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/customer-insights/arm-customerinsights/README.md b/sdk/customer-insights/arm-customerinsights/README.md index 4c0674371b16..fca618f3fd17 100644 --- a/sdk/customer-insights/arm-customerinsights/README.md +++ b/sdk/customer-insights/arm-customerinsights/README.md @@ -1,89 +1,100 @@ ## Azure CustomerInsightsManagementClient SDK for JavaScript -This package contains an isomorphic SDK for CustomerInsightsManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for CustomerInsightsManagementClient. ### 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-customerinsights +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-customerinsights` 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-customerinsights @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -``` -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```ts -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { CustomerInsightsManagementClient, CustomerInsightsManagementModels, CustomerInsightsManagementMappers } from "@azure/arm-customerinsights"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { CustomerInsightsManagementClient } = require("@azure/arm-customerinsights"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new CustomerInsightsManagementClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new CustomerInsightsManagementClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -``` -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-customerinsights sample - - + @@ -95,5 +106,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcustomer-insights%2Farm-customerinsights%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/customer-insights/arm-customerinsights/README.png) diff --git a/sdk/customer-insights/arm-customerinsights/package.json b/sdk/customer-insights/arm-customerinsights/package.json index 8da0aaac415b..89b51667d0dc 100644 --- a/sdk/customer-insights/arm-customerinsights/package.json +++ b/sdk/customer-insights/arm-customerinsights/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-customerinsights", "author": "Microsoft Corporation", "description": "CustomerInsightsManagementClient Library with typescript type definitions for node.js and browser.", - "version": "3.1.0", + "version": "3.2.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.1.0", - "@azure/ms-rest-js": "^1.1.0", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/customerInsightsManagementClient.js", "types": "./esm/customerInsightsManagementClient.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/customer-insights/arm-customerinsights/src/customerInsightsManagementClient.ts b/sdk/customer-insights/arm-customerinsights/src/customerInsightsManagementClient.ts index 756b2eaa4155..6222dfec17cc 100644 --- a/sdk/customer-insights/arm-customerinsights/src/customerInsightsManagementClient.ts +++ b/sdk/customer-insights/arm-customerinsights/src/customerInsightsManagementClient.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"; @@ -37,12 +38,17 @@ class CustomerInsightsManagementClient extends CustomerInsightsManagementClientC /** * Initializes a new instance of the CustomerInsightsManagementClient 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.CustomerInsightsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.CustomerInsightsManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.hubs = new operations.Hubs(this); diff --git a/sdk/customer-insights/arm-customerinsights/src/customerInsightsManagementClientContext.ts b/sdk/customer-insights/arm-customerinsights/src/customerInsightsManagementClientContext.ts index 90b220dba9bb..056ca9a3d8fd 100644 --- a/sdk/customer-insights/arm-customerinsights/src/customerInsightsManagementClientContext.ts +++ b/sdk/customer-insights/arm-customerinsights/src/customerInsightsManagementClientContext.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-customerinsights"; -const packageVersion = "0.1.0"; +const packageVersion = "3.2.0"; export class CustomerInsightsManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the CustomerInsightsManagementClient 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.CustomerInsightsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.CustomerInsightsManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/databox/arm-databox/README.md b/sdk/databox/arm-databox/README.md index 4a3b8f3d1504..da15b9671dab 100644 --- a/sdk/databox/arm-databox/README.md +++ b/sdk/databox/arm-databox/README.md @@ -1,90 +1,100 @@ ## Azure DataBoxManagementClient SDK for JavaScript -This package contains an isomorphic SDK for DataBoxManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for DataBoxManagementClient. ### 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-databox` 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-databox +npm install --save @azure/arm-databox @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { DataBoxManagementClient, DataBoxManagementModels, DataBoxManagementMappers } from "@azure/arm-databox"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { DataBoxManagementClient } = require("@azure/arm-databox"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new DataBoxManagementClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new DataBoxManagementClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-databox sample - - + diff --git a/sdk/databox/arm-databox/package.json b/sdk/databox/arm-databox/package.json index 4609f88a04ca..b36129702a4b 100644 --- a/sdk/databox/arm-databox/package.json +++ b/sdk/databox/arm-databox/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-databox", "author": "Microsoft Corporation", "description": "DataBoxManagementClient 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/dataBoxManagementClient.js", "types": "./esm/dataBoxManagementClient.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/databox/arm-databox/src/dataBoxManagementClient.ts b/sdk/databox/arm-databox/src/dataBoxManagementClient.ts index f602142b81a6..ef58e9ba9067 100644 --- a/sdk/databox/arm-databox/src/dataBoxManagementClient.ts +++ b/sdk/databox/arm-databox/src/dataBoxManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -23,11 +24,16 @@ class DataBoxManagementClient extends DataBoxManagementClientContext { /** * Initializes a new instance of the DataBoxManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The Subscription Id * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DataBoxManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DataBoxManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.jobs = new operations.Jobs(this); diff --git a/sdk/databox/arm-databox/src/dataBoxManagementClientContext.ts b/sdk/databox/arm-databox/src/dataBoxManagementClientContext.ts index c96e85eca2a9..dd8008144963 100644 --- a/sdk/databox/arm-databox/src/dataBoxManagementClientContext.ts +++ b/sdk/databox/arm-databox/src/dataBoxManagementClientContext.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-databox"; -const packageVersion = "4.0.0"; +const packageVersion = "4.1.0"; export class DataBoxManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the DataBoxManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The Subscription Id * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DataBoxManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DataBoxManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/README.md b/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/README.md index de4e81764af3..ce1d3af84c2d 100644 --- a/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/README.md +++ b/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/README.md @@ -1,90 +1,100 @@ ## Azure DataBoxEdgeManagementClient SDK for JavaScript -This package contains an isomorphic SDK for DataBoxEdgeManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for DataBoxEdgeManagementClient. ### 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-databoxedge-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-databoxedge-profile-2020-09-01-hybrid +npm install --save @azure/arm-databoxedge-profile-2020-09-01-hybrid @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { DataBoxEdgeManagementClient, DataBoxEdgeManagementModels, DataBoxEdgeManagementMappers } from "@azure/arm-databoxedge-profile-2020-09-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { DataBoxEdgeManagementClient } = require("@azure/arm-databoxedge-profile-2020-09-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new DataBoxEdgeManagementClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new DataBoxEdgeManagementClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-databoxedge-profile-2020-09-01-hybrid sample - - + diff --git a/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/package.json b/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/package.json index b2dfc62b4175..b3376a9cd60b 100644 --- a/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/package.json +++ b/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-databoxedge-profile-2020-09-01-hybrid", "author": "Microsoft Corporation", "description": "DataBoxEdgeManagementClient 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/dataBoxEdgeManagementClient.js", "types": "./esm/dataBoxEdgeManagementClient.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/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/src/dataBoxEdgeManagementClient.ts b/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/src/dataBoxEdgeManagementClient.ts index eb7d557efa73..5c59037970dc 100644 --- a/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/src/dataBoxEdgeManagementClient.ts +++ b/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/src/dataBoxEdgeManagementClient.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"; @@ -36,11 +37,16 @@ class DataBoxEdgeManagementClient extends DataBoxEdgeManagementClientContext { /** * Initializes a new instance of the DataBoxEdgeManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DataBoxEdgeManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DataBoxEdgeManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.devices = new operations.Devices(this); diff --git a/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/src/dataBoxEdgeManagementClientContext.ts b/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/src/dataBoxEdgeManagementClientContext.ts index fe065c028fa0..5c2a8b6738ca 100644 --- a/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/src/dataBoxEdgeManagementClientContext.ts +++ b/sdk/databoxedge/arm-databoxedge-profile-2020-09-01-hybrid/src/dataBoxEdgeManagementClientContext.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-databoxedge-profile-2020-09-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class DataBoxEdgeManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the DataBoxEdgeManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DataBoxEdgeManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DataBoxEdgeManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/databoxedge/arm-databoxedge/README.md b/sdk/databoxedge/arm-databoxedge/README.md index a577fd2649c4..53816f7385fa 100644 --- a/sdk/databoxedge/arm-databoxedge/README.md +++ b/sdk/databoxedge/arm-databoxedge/README.md @@ -1,90 +1,100 @@ ## Azure DataBoxEdgeManagementClient SDK for JavaScript -This package contains an isomorphic SDK for DataBoxEdgeManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for DataBoxEdgeManagementClient. ### 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-databoxedge` 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-databoxedge +npm install --save @azure/arm-databoxedge @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { DataBoxEdgeManagementClient, DataBoxEdgeManagementModels, DataBoxEdgeManagementMappers } from "@azure/arm-databoxedge"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { DataBoxEdgeManagementClient } = require("@azure/arm-databoxedge"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new DataBoxEdgeManagementClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new DataBoxEdgeManagementClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-databoxedge sample - - + diff --git a/sdk/databoxedge/arm-databoxedge/package.json b/sdk/databoxedge/arm-databoxedge/package.json index db93e4ac2bfd..2015769b0aa7 100644 --- a/sdk/databoxedge/arm-databoxedge/package.json +++ b/sdk/databoxedge/arm-databoxedge/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-databoxedge", "author": "Microsoft Corporation", "description": "DataBoxEdgeManagementClient 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/dataBoxEdgeManagementClient.js", "types": "./esm/dataBoxEdgeManagementClient.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/databoxedge/arm-databoxedge/src/dataBoxEdgeManagementClient.ts b/sdk/databoxedge/arm-databoxedge/src/dataBoxEdgeManagementClient.ts index eb7d557efa73..5c59037970dc 100644 --- a/sdk/databoxedge/arm-databoxedge/src/dataBoxEdgeManagementClient.ts +++ b/sdk/databoxedge/arm-databoxedge/src/dataBoxEdgeManagementClient.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"; @@ -36,11 +37,16 @@ class DataBoxEdgeManagementClient extends DataBoxEdgeManagementClientContext { /** * Initializes a new instance of the DataBoxEdgeManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DataBoxEdgeManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DataBoxEdgeManagementClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.devices = new operations.Devices(this); diff --git a/sdk/databoxedge/arm-databoxedge/src/dataBoxEdgeManagementClientContext.ts b/sdk/databoxedge/arm-databoxedge/src/dataBoxEdgeManagementClientContext.ts index 64e905bd34e6..de420a60aa07 100644 --- a/sdk/databoxedge/arm-databoxedge/src/dataBoxEdgeManagementClientContext.ts +++ b/sdk/databoxedge/arm-databoxedge/src/dataBoxEdgeManagementClientContext.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-databoxedge"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class DataBoxEdgeManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the DataBoxEdgeManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DataBoxEdgeManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DataBoxEdgeManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/datacatalog/arm-datacatalog/README.md b/sdk/datacatalog/arm-datacatalog/README.md index f8e46fc91566..bfe24b08786b 100644 --- a/sdk/datacatalog/arm-datacatalog/README.md +++ b/sdk/datacatalog/arm-datacatalog/README.md @@ -1,89 +1,100 @@ ## Azure DataCatalogRestClient SDK for JavaScript -This package contains an isomorphic SDK for DataCatalogRestClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for DataCatalogRestClient. ### 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-datacatalog +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-datacatalog` 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-datacatalog @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 aDCOperations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -``` -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list aDCOperations 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 { DataCatalogRestClient, DataCatalogRestModels, DataCatalogRestMappers } from "@azure/arm-datacatalog"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { DataCatalogRestClient } = require("@azure/arm-datacatalog"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new DataCatalogRestClient(creds, subscriptionId); - client.aDCOperations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new DataCatalogRestClient(creds, subscriptionId); + +client.aDCOperations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list aDCOperations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list aDCOperations as an example written in JavaScript. -``` -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-datacatalog sample - - + @@ -95,5 +106,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fdatacatalog%2Farm-datacatalog%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/datacatalog/arm-datacatalog/README.png) diff --git a/sdk/datacatalog/arm-datacatalog/package.json b/sdk/datacatalog/arm-datacatalog/package.json index a6156ca2efa3..ddfea4198254 100644 --- a/sdk/datacatalog/arm-datacatalog/package.json +++ b/sdk/datacatalog/arm-datacatalog/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-datacatalog", "author": "Microsoft Corporation", "description": "DataCatalogRestClient Library with typescript type definitions for node.js and browser.", - "version": "1.1.0", + "version": "1.2.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.1.0", - "@azure/ms-rest-js": "^1.1.0", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/dataCatalogRestClient.js", "types": "./esm/dataCatalogRestClient.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/datacatalog/arm-datacatalog/src/dataCatalogRestClient.ts b/sdk/datacatalog/arm-datacatalog/src/dataCatalogRestClient.ts index 4aa9c94fa9ea..81ff23bff504 100644 --- a/sdk/datacatalog/arm-datacatalog/src/dataCatalogRestClient.ts +++ b/sdk/datacatalog/arm-datacatalog/src/dataCatalogRestClient.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,13 +23,18 @@ class DataCatalogRestClient extends DataCatalogRestClientContext { /** * Initializes a new instance of the DataCatalogRestClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Gets subscription credentials which uniquely identify the Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param catalogName The name of the data catlog in the specified subscription and resource group. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, catalogName: string, options?: Models.DataCatalogRestClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, catalogName: string, options?: Models.DataCatalogRestClientOptions) { super(credentials, subscriptionId, catalogName, options); this.aDCOperations = new operations.ADCOperations(this); this.aDCCatalogs = new operations.ADCCatalogs(this); diff --git a/sdk/datacatalog/arm-datacatalog/src/dataCatalogRestClientContext.ts b/sdk/datacatalog/arm-datacatalog/src/dataCatalogRestClientContext.ts index 625a2fd045b7..80b966832bdc 100644 --- a/sdk/datacatalog/arm-datacatalog/src/dataCatalogRestClientContext.ts +++ b/sdk/datacatalog/arm-datacatalog/src/dataCatalogRestClientContext.ts @@ -10,26 +10,32 @@ 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-datacatalog"; -const packageVersion = "0.1.0"; +const packageVersion = "1.2.0"; export class DataCatalogRestClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; catalogName: string; /** * Initializes a new instance of the DataCatalogRestClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Gets subscription credentials which uniquely identify the Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param catalogName The name of the data catlog in the specified subscription and resource group. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, catalogName: string, options?: Models.DataCatalogRestClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, catalogName: string, options?: Models.DataCatalogRestClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/datadog/arm-datadog/README.md b/sdk/datadog/arm-datadog/README.md index a20955120dc4..3896344cab4d 100644 --- a/sdk/datadog/arm-datadog/README.md +++ b/sdk/datadog/arm-datadog/README.md @@ -1,89 +1,100 @@ ## Azure MicrosoftDatadogClient SDK for JavaScript -This package contains an isomorphic SDK for MicrosoftDatadogClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for MicrosoftDatadogClient. ### 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-datadog` 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-datadog +npm install --save @azure/arm-datadog @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - client creation and list marketplaceAgreements 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 marketplaceAgreements 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 { MicrosoftDatadogClient } = require("@azure/arm-datadog"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new MicrosoftDatadogClient(creds, subscriptionId); - client.marketplaceAgreements.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new MicrosoftDatadogClient(creds, subscriptionId); + +client.marketplaceAgreements.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list marketplaceAgreements as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list marketplaceAgreements as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-datadog sample - - + diff --git a/sdk/datadog/arm-datadog/package.json b/sdk/datadog/arm-datadog/package.json index b82c25bf66fd..b72d38cfd121 100644 --- a/sdk/datadog/arm-datadog/package.json +++ b/sdk/datadog/arm-datadog/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-datadog", "author": "Microsoft Corporation", "description": "MicrosoftDatadogClient 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/microsoftDatadogClient.js", "types": "./esm/microsoftDatadogClient.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/datadog/arm-datadog/src/microsoftDatadogClient.ts b/sdk/datadog/arm-datadog/src/microsoftDatadogClient.ts index 5098f57e6721..2bf92969c7a8 100644 --- a/sdk/datadog/arm-datadog/src/microsoftDatadogClient.ts +++ b/sdk/datadog/arm-datadog/src/microsoftDatadogClient.ts @@ -8,6 +8,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -24,11 +25,16 @@ class MicrosoftDatadogClient extends MicrosoftDatadogClientContext { /** * Initializes a new instance of the MicrosoftDatadogClient 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.MicrosoftDatadogClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.MicrosoftDatadogClientOptions) { super(credentials, subscriptionId, options); this.marketplaceAgreements = new operations.MarketplaceAgreements(this); this.monitors = new operations.Monitors(this); diff --git a/sdk/datadog/arm-datadog/src/microsoftDatadogClientContext.ts b/sdk/datadog/arm-datadog/src/microsoftDatadogClientContext.ts index 6c3e2a613997..098cb8df85c7 100644 --- a/sdk/datadog/arm-datadog/src/microsoftDatadogClientContext.ts +++ b/sdk/datadog/arm-datadog/src/microsoftDatadogClientContext.ts @@ -9,24 +9,30 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-datadog"; -const packageVersion = "2.0.0"; +const packageVersion = "2.1.0"; export class MicrosoftDatadogClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the MicrosoftDatadogClient 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.MicrosoftDatadogClientOptions ) { diff --git a/sdk/datalake-analytics/arm-datalake-analytics/README.md b/sdk/datalake-analytics/arm-datalake-analytics/README.md index 79c4361896d1..d6f15d764fac 100644 --- a/sdk/datalake-analytics/arm-datalake-analytics/README.md +++ b/sdk/datalake-analytics/arm-datalake-analytics/README.md @@ -1,101 +1,111 @@ ## Azure DataLakeAnalyticsAccountManagementClient SDK for JavaScript -This package contains an isomorphic SDK for DataLakeAnalyticsAccountManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for DataLakeAnalyticsAccountManagementClient. ### 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-datalake-analytics` 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-datalake-analytics +npm install --save @azure/arm-datalake-analytics @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - client creation and list accounts 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 accounts 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 { DataLakeAnalyticsAccountManagementClient } = require("@azure/arm-datalake-analytics"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new DataLakeAnalyticsAccountManagementClient(creds, subscriptionId); - const filter = "testfilter"; - const top = 1; - const skip = 1; - const select = "testselect"; - const orderby = "testorderby"; - const count = true; - client.accounts.list(filter, top, skip, select, orderby, count).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 DataLakeAnalyticsAccountManagementClient(creds, subscriptionId); +const filter = "testfilter"; +const top = 1; +const skip = 1; +const select = "testselect"; +const orderby = "testorderby"; +const count = true; +client.accounts.list(filter, top, skip, select, orderby, count).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 accounts as an example written in JavaScript. +#### browser - Authentication, client creation, and list accounts 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-datalake-analytics sample - - + diff --git a/sdk/datalake-analytics/arm-datalake-analytics/package.json b/sdk/datalake-analytics/arm-datalake-analytics/package.json index bc834bc3ef9e..2b5c2dc3b789 100644 --- a/sdk/datalake-analytics/arm-datalake-analytics/package.json +++ b/sdk/datalake-analytics/arm-datalake-analytics/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-datalake-analytics", "author": "Microsoft Corporation", "description": "DataLakeAnalyticsAccountManagementClient 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/dataLakeAnalyticsAccountManagementClient.js", "types": "./esm/dataLakeAnalyticsAccountManagementClient.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/datalake-analytics/arm-datalake-analytics/src/dataLakeAnalyticsAccountManagementClient.ts b/sdk/datalake-analytics/arm-datalake-analytics/src/dataLakeAnalyticsAccountManagementClient.ts index a91597e62ced..9f5e7ff53f1e 100644 --- a/sdk/datalake-analytics/arm-datalake-analytics/src/dataLakeAnalyticsAccountManagementClient.ts +++ b/sdk/datalake-analytics/arm-datalake-analytics/src/dataLakeAnalyticsAccountManagementClient.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"; @@ -26,12 +27,17 @@ class DataLakeAnalyticsAccountManagementClient extends DataLakeAnalyticsAccountM /** * Initializes a new instance of the DataLakeAnalyticsAccountManagementClient 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 Get 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.DataLakeAnalyticsAccountManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DataLakeAnalyticsAccountManagementClientOptions) { super(credentials, subscriptionId, options); this.accounts = new operations.Accounts(this); this.dataLakeStoreAccounts = new operations.DataLakeStoreAccounts(this); diff --git a/sdk/datalake-analytics/arm-datalake-analytics/src/dataLakeAnalyticsAccountManagementClientContext.ts b/sdk/datalake-analytics/arm-datalake-analytics/src/dataLakeAnalyticsAccountManagementClientContext.ts index 4e527da3fa69..748544f2f1e7 100644 --- a/sdk/datalake-analytics/arm-datalake-analytics/src/dataLakeAnalyticsAccountManagementClientContext.ts +++ b/sdk/datalake-analytics/arm-datalake-analytics/src/dataLakeAnalyticsAccountManagementClientContext.ts @@ -9,24 +9,30 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as msRestAzure from "@azure/ms-rest-azure-js"; const packageName = "@azure/arm-datalake-analytics"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class DataLakeAnalyticsAccountManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the DataLakeAnalyticsAccountManagementClient 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 Get 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.DataLakeAnalyticsAccountManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DataLakeAnalyticsAccountManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/datamigration/arm-datamigration/README.md b/sdk/datamigration/arm-datamigration/README.md index d6b3a84c59a5..6868b32fb3ef 100644 --- a/sdk/datamigration/arm-datamigration/README.md +++ b/sdk/datamigration/arm-datamigration/README.md @@ -1,90 +1,100 @@ ## Azure DataMigrationServiceClient SDK for JavaScript -This package contains an isomorphic SDK for DataMigrationServiceClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for DataMigrationServiceClient. ### 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-datamigration` 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-datamigration +npm install --save @azure/arm-datamigration @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 listSkus resourceSkus 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 listSkus resourceSkus 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 { DataMigrationServiceClient, DataMigrationServiceModels, DataMigrationServiceMappers } from "@azure/arm-datamigration"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { DataMigrationServiceClient } = require("@azure/arm-datamigration"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new DataMigrationServiceClient(creds, subscriptionId); - client.resourceSkus.listSkus().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 DataMigrationServiceClient(creds, subscriptionId); + +client.resourceSkus.listSkus().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 listSkus resourceSkus as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and listSkus resourceSkus as an example written in JavaScript. -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-datamigration sample - - + @@ -96,4 +106,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fdatamigration%2Farm-datamigration%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/datamigration/arm-datamigration/README.png) diff --git a/sdk/datamigration/arm-datamigration/package.json b/sdk/datamigration/arm-datamigration/package.json index f3836232e42b..a43508d985e7 100644 --- a/sdk/datamigration/arm-datamigration/package.json +++ b/sdk/datamigration/arm-datamigration/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-datamigration", "author": "Microsoft Corporation", "description": "DataMigrationServiceClient 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/dataMigrationServiceClient.js", "types": "./esm/dataMigrationServiceClient.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/datamigration/arm-datamigration/src/dataMigrationServiceClient.ts b/sdk/datamigration/arm-datamigration/src/dataMigrationServiceClient.ts index 62d5230fee13..25396551b380 100644 --- a/sdk/datamigration/arm-datamigration/src/dataMigrationServiceClient.ts +++ b/sdk/datamigration/arm-datamigration/src/dataMigrationServiceClient.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"; @@ -28,11 +29,16 @@ class DataMigrationServiceClient extends DataMigrationServiceClientContext { /** * Initializes a new instance of the DataMigrationServiceClient 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 Identifier of the subscription * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DataMigrationServiceClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DataMigrationServiceClientOptions) { super(credentials, subscriptionId, options); this.resourceSkus = new operations.ResourceSkus(this); this.services = new operations.Services(this); diff --git a/sdk/datamigration/arm-datamigration/src/dataMigrationServiceClientContext.ts b/sdk/datamigration/arm-datamigration/src/dataMigrationServiceClientContext.ts index 6a0937753ff2..69901d9c9581 100644 --- a/sdk/datamigration/arm-datamigration/src/dataMigrationServiceClientContext.ts +++ b/sdk/datamigration/arm-datamigration/src/dataMigrationServiceClientContext.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-datamigration"; -const packageVersion = "1.0.1"; +const packageVersion = "2.1.0"; export class DataMigrationServiceClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the DataMigrationServiceClient 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 Identifier of the subscription * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DataMigrationServiceClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DataMigrationServiceClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/deploymentmanager/arm-deploymentmanager/README.md b/sdk/deploymentmanager/arm-deploymentmanager/README.md index a3a985772bf3..1e3949dc85e0 100644 --- a/sdk/deploymentmanager/arm-deploymentmanager/README.md +++ b/sdk/deploymentmanager/arm-deploymentmanager/README.md @@ -1,94 +1,103 @@ ## Azure AzureDeploymentManager SDK for JavaScript -This package contains an isomorphic SDK for AzureDeploymentManager. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AzureDeploymentManager. ### 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-deploymentmanager` 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-deploymentmanager +npm install --save @azure/arm-deploymentmanager @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 serviceTopologies 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 serviceTopologies 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 { AzureDeploymentManager, AzureDeploymentManagerModels, AzureDeploymentManagerMappers } from "@azure/arm-deploymentmanager"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { AzureDeploymentManager } = require("@azure/arm-deploymentmanager"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AzureDeploymentManager(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const serviceTopologyName = "testserviceTopologyName"; - client.serviceTopologies.get(resourceGroupName, serviceTopologyName).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 AzureDeploymentManager(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const serviceTopologyName = "testserviceTopologyName"; +client.serviceTopologies.get(resourceGroupName, serviceTopologyName).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 serviceTopologies as an example written in JavaScript. +#### browser - Authentication, client creation, and get serviceTopologies 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-deploymentmanager sample - - + diff --git a/sdk/deploymentmanager/arm-deploymentmanager/package.json b/sdk/deploymentmanager/arm-deploymentmanager/package.json index 9f1b9483e37f..90ff4f703456 100644 --- a/sdk/deploymentmanager/arm-deploymentmanager/package.json +++ b/sdk/deploymentmanager/arm-deploymentmanager/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-deploymentmanager", "author": "Microsoft Corporation", "description": "AzureDeploymentManager Library with typescript type definitions for node.js and browser.", - "version": "3.0.0", + "version": "3.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/azureDeploymentManager.js", "types": "./esm/azureDeploymentManager.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/deploymentmanager/arm-deploymentmanager/src/azureDeploymentManager.ts b/sdk/deploymentmanager/arm-deploymentmanager/src/azureDeploymentManager.ts index f948ddd290cd..d45c245be8ee 100644 --- a/sdk/deploymentmanager/arm-deploymentmanager/src/azureDeploymentManager.ts +++ b/sdk/deploymentmanager/arm-deploymentmanager/src/azureDeploymentManager.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -27,12 +28,17 @@ class AzureDeploymentManager extends AzureDeploymentManagerContext { /** * Initializes a new instance of the AzureDeploymentManager class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials 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.AzureDeploymentManagerOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureDeploymentManagerOptions) { super(credentials, subscriptionId, options); this.serviceTopologies = new operations.ServiceTopologies(this); this.services = new operations.Services(this); diff --git a/sdk/deploymentmanager/arm-deploymentmanager/src/azureDeploymentManagerContext.ts b/sdk/deploymentmanager/arm-deploymentmanager/src/azureDeploymentManagerContext.ts index 397f56cb3595..fb0ea8f030d6 100644 --- a/sdk/deploymentmanager/arm-deploymentmanager/src/azureDeploymentManagerContext.ts +++ b/sdk/deploymentmanager/arm-deploymentmanager/src/azureDeploymentManagerContext.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-deploymentmanager"; -const packageVersion = "3.0.0"; +const packageVersion = "3.1.0"; export class AzureDeploymentManagerContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the AzureDeploymentManager class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Subscription credentials 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.AzureDeploymentManagerOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureDeploymentManagerOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/README.md b/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/README.md index a3ee467ae318..4338b81b9f77 100644 --- a/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/README.md +++ b/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/README.md @@ -1,89 +1,100 @@ ## Azure IotDpsClient SDK for JavaScript -This package contains an isomorphic SDK for IotDpsClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for IotDpsClient. ### 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-deviceprovisioningservices +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-deviceprovisioningservices` 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-deviceprovisioningservices @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -``` -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript. ##### Sample code -```ts -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { IotDpsClient, IotDpsModels, IotDpsMappers } from "@azure/arm-deviceprovisioningservices"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { IotDpsClient } = require("@azure/arm-deviceprovisioningservices"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new IotDpsClient(creds, subscriptionId); - client.operations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new IotDpsClient(creds, subscriptionId); + +client.operations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list operations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list operations as an example written in JavaScript. -``` -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-deviceprovisioningservices sample - - + @@ -95,5 +106,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fdeviceprovisioningservices%2Farm-deviceprovisioningservices%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/README.png) diff --git a/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/package.json b/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/package.json index a1f070d5456d..bbca9abf56cb 100644 --- a/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/package.json +++ b/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-deviceprovisioningservices", "author": "Microsoft Corporation", "description": "IotDpsClient Library with typescript type definitions for node.js and browser.", - "version": "2.1.0", + "version": "2.2.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.1.0", - "@azure/ms-rest-js": "^1.1.0", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/iotDpsClient.js", "types": "./esm/iotDpsClient.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/deviceprovisioningservices/arm-deviceprovisioningservices/src/iotDpsClient.ts b/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/src/iotDpsClient.ts index b5b09d14c58d..12a7443f5b95 100644 --- a/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/src/iotDpsClient.ts +++ b/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/src/iotDpsClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -23,11 +24,16 @@ class IotDpsClient extends IotDpsClientContext { /** * Initializes a new instance of the IotDpsClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription identifier. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.IotDpsClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.IotDpsClientOptions) { super(credentials, subscriptionId, options); this.operations = new operations.Operations(this); this.dpsCertificate = new operations.DpsCertificate(this); diff --git a/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/src/iotDpsClientContext.ts b/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/src/iotDpsClientContext.ts index 48146b6d20a3..c331f7277b8e 100644 --- a/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/src/iotDpsClientContext.ts +++ b/sdk/deviceprovisioningservices/arm-deviceprovisioningservices/src/iotDpsClientContext.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-deviceprovisioningservices"; -const packageVersion = "0.1.0"; +const packageVersion = "2.2.0"; export class IotDpsClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the IotDpsClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription identifier. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.IotDpsClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.IotDpsClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/devspaces/arm-devspaces/README.md b/sdk/devspaces/arm-devspaces/README.md index 5f5f691cba70..1f4b6113bdda 100644 --- a/sdk/devspaces/arm-devspaces/README.md +++ b/sdk/devspaces/arm-devspaces/README.md @@ -1,93 +1,103 @@ ## Azure DevSpacesManagementClient SDK for JavaScript -This package contains an isomorphic SDK for DevSpacesManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for DevSpacesManagementClient. ### 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-devspaces +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-devspaces` 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-devspaces @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 controllers as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -``` -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and get controllers 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 { DevSpacesManagementClient, DevSpacesManagementModels, DevSpacesManagementMappers } from "@azure/arm-devspaces"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { DevSpacesManagementClient } = require("@azure/arm-devspaces"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new DevSpacesManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const name = "testname"; - client.controllers.get(resourceGroupName, name).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 DevSpacesManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const name = "testname"; +client.controllers.get(resourceGroupName, name).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 controllers as an example written in JavaScript. +#### browser - Authentication, client creation, and get controllers 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-devspaces 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%2Fdevspaces%2Farm-devspaces%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/devspaces/arm-devspaces/README.png) diff --git a/sdk/devspaces/arm-devspaces/package.json b/sdk/devspaces/arm-devspaces/package.json index 186018c67a51..f03e14c74c35 100644 --- a/sdk/devspaces/arm-devspaces/package.json +++ b/sdk/devspaces/arm-devspaces/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-devspaces", "author": "Microsoft Corporation", "description": "DevSpacesManagementClient Library with typescript type definitions for node.js and browser.", - "version": "1.1.0", + "version": "1.2.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.1.0", - "@azure/ms-rest-js": "^1.1.0", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/devSpacesManagementClient.js", "types": "./esm/devSpacesManagementClient.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/devspaces/arm-devspaces/src/devSpacesManagementClient.ts b/sdk/devspaces/arm-devspaces/src/devSpacesManagementClient.ts index be116e003310..e01c000e3052 100644 --- a/sdk/devspaces/arm-devspaces/src/devSpacesManagementClient.ts +++ b/sdk/devspaces/arm-devspaces/src/devSpacesManagementClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -23,11 +24,16 @@ class DevSpacesManagementClient extends DevSpacesManagementClientContext { /** * Initializes a new instance of the DevSpacesManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Azure subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DevSpacesManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DevSpacesManagementClientOptions) { super(credentials, subscriptionId, options); this.containerHostMappings = new operations.ContainerHostMappings(this); this.controllers = new operations.Controllers(this); diff --git a/sdk/devspaces/arm-devspaces/src/devSpacesManagementClientContext.ts b/sdk/devspaces/arm-devspaces/src/devSpacesManagementClientContext.ts index 1369a6260a07..b2b8060c0769 100644 --- a/sdk/devspaces/arm-devspaces/src/devSpacesManagementClientContext.ts +++ b/sdk/devspaces/arm-devspaces/src/devSpacesManagementClientContext.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-devspaces"; -const packageVersion = "0.1.0"; +const packageVersion = "1.2.0"; export class DevSpacesManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the DevSpacesManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Azure subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DevSpacesManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DevSpacesManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/devtestlabs/arm-devtestlabs/README.md b/sdk/devtestlabs/arm-devtestlabs/README.md index f00489748b4a..884a722c47aa 100644 --- a/sdk/devtestlabs/arm-devtestlabs/README.md +++ b/sdk/devtestlabs/arm-devtestlabs/README.md @@ -1,89 +1,100 @@ ## Azure DevTestLabsClient SDK for JavaScript -This package contains an isomorphic SDK for DevTestLabsClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for DevTestLabsClient. ### 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-devtestlabs` 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-devtestlabs +npm install --save @azure/arm-devtestlabs @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 providerOperations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -```bash -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list providerOperations 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 { DevTestLabsClient, DevTestLabsModels, DevTestLabsMappers } from "@azure/arm-devtestlabs"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { DevTestLabsClient } = require("@azure/arm-devtestlabs"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new DevTestLabsClient(creds, subscriptionId); - client.providerOperations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new DevTestLabsClient(creds, subscriptionId); + +client.providerOperations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list providerOperations as an example written in JavaScript. +#### browser - Authentication, client creation, and list providerOperations 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-devtestlabs sample - - + @@ -95,5 +106,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fdevtestlabs%2Farm-devtestlabs%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/devtestlabs/arm-devtestlabs/README.png) diff --git a/sdk/devtestlabs/arm-devtestlabs/package.json b/sdk/devtestlabs/arm-devtestlabs/package.json index bbe78efddd6d..28853c7a5ef9 100644 --- a/sdk/devtestlabs/arm-devtestlabs/package.json +++ b/sdk/devtestlabs/arm-devtestlabs/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-devtestlabs", "author": "Microsoft Corporation", "description": "DevTestLabsClient Library with typescript type definitions for node.js and browser.", - "version": "3.2.0", + "version": "3.3.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.3.1", - "@azure/ms-rest-js": "^1.2.6", + "@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/devTestLabsClient.js", "types": "./esm/devTestLabsClient.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/devtestlabs/arm-devtestlabs/src/devTestLabsClient.ts b/sdk/devtestlabs/arm-devtestlabs/src/devTestLabsClient.ts index 3661410b1c1e..d65f2ffacb1f 100644 --- a/sdk/devtestlabs/arm-devtestlabs/src/devTestLabsClient.ts +++ b/sdk/devtestlabs/arm-devtestlabs/src/devTestLabsClient.ts @@ -9,6 +9,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -45,11 +46,16 @@ class DevTestLabsClient extends DevTestLabsClientContext { /** * Initializes a new instance of the DevTestLabsClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DevTestLabsClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DevTestLabsClientOptions) { super(credentials, subscriptionId, options); this.providerOperations = new operations.ProviderOperations(this); this.labs = new operations.Labs(this); diff --git a/sdk/devtestlabs/arm-devtestlabs/src/devTestLabsClientContext.ts b/sdk/devtestlabs/arm-devtestlabs/src/devTestLabsClientContext.ts index 4ea49aa18b6a..b0b4ead147db 100644 --- a/sdk/devtestlabs/arm-devtestlabs/src/devTestLabsClientContext.ts +++ b/sdk/devtestlabs/arm-devtestlabs/src/devTestLabsClientContext.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-devtestlabs"; -const packageVersion = "1.0.0"; +const packageVersion = "3.3.0"; export class DevTestLabsClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; apiVersion?: string; subscriptionId: string; /** * Initializes a new instance of the DevTestLabsClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription ID. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DevTestLabsClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DevTestLabsClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/digitaltwins/arm-digitaltwins/README.md b/sdk/digitaltwins/arm-digitaltwins/README.md index 0f74fb4e79d7..48d9191e17e0 100644 --- a/sdk/digitaltwins/arm-digitaltwins/README.md +++ b/sdk/digitaltwins/arm-digitaltwins/README.md @@ -1,93 +1,103 @@ ## Azure AzureDigitalTwinsManagementClient SDK for JavaScript -This package contains an isomorphic SDK for AzureDigitalTwinsManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AzureDigitalTwinsManagementClient. ### 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-digitaltwins` 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-digitaltwins +npm install --save @azure/arm-digitaltwins @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 digitalTwins 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 digitalTwins 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 { AzureDigitalTwinsManagementClient } = require("@azure/arm-digitaltwins"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new AzureDigitalTwinsManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const resourceName = "testresourceName"; - client.digitalTwins.get(resourceGroupName, resourceName).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 AzureDigitalTwinsManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const resourceName = "testresourceName"; +client.digitalTwins.get(resourceGroupName, resourceName).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 digitalTwins as an example written in JavaScript. +#### browser - Authentication, client creation, and get digitalTwins 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-digitaltwins sample - - + diff --git a/sdk/digitaltwins/arm-digitaltwins/package.json b/sdk/digitaltwins/arm-digitaltwins/package.json index dd9176307257..6aacd298921d 100644 --- a/sdk/digitaltwins/arm-digitaltwins/package.json +++ b/sdk/digitaltwins/arm-digitaltwins/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-digitaltwins", "author": "Microsoft Corporation", "description": "AzureDigitalTwinsManagementClient 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/azureDigitalTwinsManagementClient.js", "types": "./esm/azureDigitalTwinsManagementClient.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/digitaltwins/arm-digitaltwins/src/azureDigitalTwinsManagementClient.ts b/sdk/digitaltwins/arm-digitaltwins/src/azureDigitalTwinsManagementClient.ts index a2c8ab2fc8ab..9a9bf51be733 100644 --- a/sdk/digitaltwins/arm-digitaltwins/src/azureDigitalTwinsManagementClient.ts +++ b/sdk/digitaltwins/arm-digitaltwins/src/azureDigitalTwinsManagementClient.ts @@ -8,6 +8,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -24,11 +25,16 @@ class AzureDigitalTwinsManagementClient extends AzureDigitalTwinsManagementClien /** * Initializes a new instance of the AzureDigitalTwinsManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription identifier. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.AzureDigitalTwinsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureDigitalTwinsManagementClientOptions) { super(credentials, subscriptionId, options); this.digitalTwins = new operations.DigitalTwins(this); this.digitalTwinsEndpoint = new operations.DigitalTwinsEndpoint(this); diff --git a/sdk/digitaltwins/arm-digitaltwins/src/azureDigitalTwinsManagementClientContext.ts b/sdk/digitaltwins/arm-digitaltwins/src/azureDigitalTwinsManagementClientContext.ts index be8bdb2c9c96..ee784856c160 100644 --- a/sdk/digitaltwins/arm-digitaltwins/src/azureDigitalTwinsManagementClientContext.ts +++ b/sdk/digitaltwins/arm-digitaltwins/src/azureDigitalTwinsManagementClientContext.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-digitaltwins"; -const packageVersion = "2.0.0"; +const packageVersion = "2.1.0"; export class AzureDigitalTwinsManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the AzureDigitalTwinsManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription identifier. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.AzureDigitalTwinsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureDigitalTwinsManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/dns/arm-dns-profile-2019-03-01-hybrid/README.md b/sdk/dns/arm-dns-profile-2019-03-01-hybrid/README.md index 76c4e0b8ac49..2154ff925b42 100644 --- a/sdk/dns/arm-dns-profile-2019-03-01-hybrid/README.md +++ b/sdk/dns/arm-dns-profile-2019-03-01-hybrid/README.md @@ -1,97 +1,107 @@ ## Azure DnsManagementClient SDK for JavaScript -This package contains an isomorphic SDK for DnsManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for DnsManagementClient. ### 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-dns-profile-2019-03-01-hybrid` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/arm-dns-profile-2019-03-01-hybrid +npm install --save @azure/arm-dns-profile-2019-03-01-hybrid @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. + ### How to use -#### nodejs - Authentication, client creation and get recordSets 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 recordSets 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 { DnsManagementClient, DnsManagementModels, DnsManagementMappers } from "@azure/arm-dns-profile-2019-03-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { DnsManagementClient } = require("@azure/arm-dns-profile-2019-03-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new DnsManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const zoneName = "testzoneName"; - const relativeRecordSetName = "testrelativeRecordSetName"; - const recordType = "A"; - client.recordSets.get(resourceGroupName, zoneName, relativeRecordSetName, recordType).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 DnsManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const zoneName = "testzoneName"; +const relativeRecordSetName = "testrelativeRecordSetName"; +const recordType = "A"; +client.recordSets.get(resourceGroupName, zoneName, relativeRecordSetName, recordType).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 recordSets as an example written in JavaScript. +#### browser - Authentication, client creation, and get recordSets 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-dns-profile-2019-03-01-hybrid sample - - + @@ -103,5 +113,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%2Fdns%2Farm-dns-profile-2019-03-01-hybrid%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/dns/arm-dns-profile-2019-03-01-hybrid/README.png) diff --git a/sdk/dns/arm-dns-profile-2019-03-01-hybrid/package.json b/sdk/dns/arm-dns-profile-2019-03-01-hybrid/package.json index dbd3f9650f7e..b56a0ef5a27f 100644 --- a/sdk/dns/arm-dns-profile-2019-03-01-hybrid/package.json +++ b/sdk/dns/arm-dns-profile-2019-03-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-dns-profile-2019-03-01-hybrid", "author": "Microsoft Corporation", "description": "DnsManagementClient 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/dnsManagementClient.js", "types": "./esm/dnsManagementClient.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/dns/arm-dns-profile-2019-03-01-hybrid/src/dnsManagementClient.ts b/sdk/dns/arm-dns-profile-2019-03-01-hybrid/src/dnsManagementClient.ts index 3e6f9a758eea..422ab30a3daf 100644 --- a/sdk/dns/arm-dns-profile-2019-03-01-hybrid/src/dnsManagementClient.ts +++ b/sdk/dns/arm-dns-profile-2019-03-01-hybrid/src/dnsManagementClient.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 DnsManagementClient extends DnsManagementClientContext { /** * Initializes a new instance of the DnsManagementClient 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.DnsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DnsManagementClientOptions) { super(credentials, subscriptionId, options); this.recordSets = new operations.RecordSets(this); this.zones = new operations.Zones(this); diff --git a/sdk/dns/arm-dns-profile-2019-03-01-hybrid/src/dnsManagementClientContext.ts b/sdk/dns/arm-dns-profile-2019-03-01-hybrid/src/dnsManagementClientContext.ts index 19ef9e342abf..b7213d730aaa 100644 --- a/sdk/dns/arm-dns-profile-2019-03-01-hybrid/src/dnsManagementClientContext.ts +++ b/sdk/dns/arm-dns-profile-2019-03-01-hybrid/src/dnsManagementClientContext.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-dns-profile-2019-03-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class DnsManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the DnsManagementClient 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.DnsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DnsManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/dns/arm-dns-profile-2020-09-01-hybrid/README.md b/sdk/dns/arm-dns-profile-2020-09-01-hybrid/README.md index 5c7f88c4d415..dc171426c710 100644 --- a/sdk/dns/arm-dns-profile-2020-09-01-hybrid/README.md +++ b/sdk/dns/arm-dns-profile-2020-09-01-hybrid/README.md @@ -1,98 +1,107 @@ ## Azure DnsManagementClient SDK for JavaScript -This package contains an isomorphic SDK for DnsManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for DnsManagementClient. ### 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-dns-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-dns-profile-2020-09-01-hybrid +npm install --save @azure/arm-dns-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 recordSets 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 recordSets 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 { DnsManagementClient, DnsManagementModels, DnsManagementMappers } from "@azure/arm-dns-profile-2020-09-01-hybrid"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { DnsManagementClient } = require("@azure/arm-dns-profile-2020-09-01-hybrid"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new DnsManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const zoneName = "testzoneName"; - const relativeRecordSetName = "testrelativeRecordSetName"; - const recordType = "A"; - client.recordSets.get(resourceGroupName, zoneName, relativeRecordSetName, recordType).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 DnsManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const zoneName = "testzoneName"; +const relativeRecordSetName = "testrelativeRecordSetName"; +const recordType = "A"; +client.recordSets.get(resourceGroupName, zoneName, relativeRecordSetName, recordType).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 recordSets as an example written in JavaScript. +#### browser - Authentication, client creation, and get recordSets 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-dns-profile-2020-09-01-hybrid sample - - + diff --git a/sdk/dns/arm-dns-profile-2020-09-01-hybrid/package.json b/sdk/dns/arm-dns-profile-2020-09-01-hybrid/package.json index cf5528d17c64..5a483aeed58a 100644 --- a/sdk/dns/arm-dns-profile-2020-09-01-hybrid/package.json +++ b/sdk/dns/arm-dns-profile-2020-09-01-hybrid/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-dns-profile-2020-09-01-hybrid", "author": "Microsoft Corporation", "description": "DnsManagementClient 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/dnsManagementClient.js", "types": "./esm/dnsManagementClient.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/dns/arm-dns-profile-2020-09-01-hybrid/src/dnsManagementClient.ts b/sdk/dns/arm-dns-profile-2020-09-01-hybrid/src/dnsManagementClient.ts index 3e6f9a758eea..422ab30a3daf 100644 --- a/sdk/dns/arm-dns-profile-2020-09-01-hybrid/src/dnsManagementClient.ts +++ b/sdk/dns/arm-dns-profile-2020-09-01-hybrid/src/dnsManagementClient.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 DnsManagementClient extends DnsManagementClientContext { /** * Initializes a new instance of the DnsManagementClient 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.DnsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DnsManagementClientOptions) { super(credentials, subscriptionId, options); this.recordSets = new operations.RecordSets(this); this.zones = new operations.Zones(this); diff --git a/sdk/dns/arm-dns-profile-2020-09-01-hybrid/src/dnsManagementClientContext.ts b/sdk/dns/arm-dns-profile-2020-09-01-hybrid/src/dnsManagementClientContext.ts index fd9507aacb1c..be7bd08f580f 100644 --- a/sdk/dns/arm-dns-profile-2020-09-01-hybrid/src/dnsManagementClientContext.ts +++ b/sdk/dns/arm-dns-profile-2020-09-01-hybrid/src/dnsManagementClientContext.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-dns-profile-2020-09-01-hybrid"; -const packageVersion = "1.0.0"; +const packageVersion = "1.1.0"; export class DnsManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the DnsManagementClient 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.DnsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DnsManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/dns/arm-dns/README.md b/sdk/dns/arm-dns/README.md index a298c815d4ab..806e1ac8583a 100644 --- a/sdk/dns/arm-dns/README.md +++ b/sdk/dns/arm-dns/README.md @@ -1,98 +1,107 @@ ## Azure DnsManagementClient SDK for JavaScript -This package contains an isomorphic SDK for DnsManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for DnsManagementClient. ### 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-dns` 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-dns +npm install --save @azure/arm-dns @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 recordSets 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 recordSets 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 { DnsManagementClient, DnsManagementModels, DnsManagementMappers } from "@azure/arm-dns"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { DnsManagementClient } = require("@azure/arm-dns"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new DnsManagementClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const zoneName = "testzoneName"; - const relativeRecordSetName = "testrelativeRecordSetName"; - const recordType = "A"; - client.recordSets.get(resourceGroupName, zoneName, relativeRecordSetName, recordType).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 DnsManagementClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const zoneName = "testzoneName"; +const relativeRecordSetName = "testrelativeRecordSetName"; +const recordType = "A"; +client.recordSets.get(resourceGroupName, zoneName, relativeRecordSetName, recordType).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 recordSets as an example written in JavaScript. +#### browser - Authentication, client creation, and get recordSets 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-dns sample - - + diff --git a/sdk/dns/arm-dns/package.json b/sdk/dns/arm-dns/package.json index e98d95a3c239..eb6cee0c9b59 100644 --- a/sdk/dns/arm-dns/package.json +++ b/sdk/dns/arm-dns/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-dns", "author": "Microsoft Corporation", "description": "DnsManagementClient 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/dnsManagementClient.js", "types": "./esm/dnsManagementClient.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/dns/arm-dns/src/dnsManagementClient.ts b/sdk/dns/arm-dns/src/dnsManagementClient.ts index c2142deb6643..5a7d85c07575 100644 --- a/sdk/dns/arm-dns/src/dnsManagementClient.ts +++ b/sdk/dns/arm-dns/src/dnsManagementClient.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 DnsManagementClient extends DnsManagementClientContext { /** * Initializes a new instance of the DnsManagementClient 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 Specifies the Azure subscription ID, which uniquely identifies the * Microsoft Azure subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DnsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DnsManagementClientOptions) { super(credentials, subscriptionId, options); this.recordSets = new operations.RecordSets(this); this.zones = new operations.Zones(this); diff --git a/sdk/dns/arm-dns/src/dnsManagementClientContext.ts b/sdk/dns/arm-dns/src/dnsManagementClientContext.ts index f4deb26940ab..f11d7d427648 100644 --- a/sdk/dns/arm-dns/src/dnsManagementClientContext.ts +++ b/sdk/dns/arm-dns/src/dnsManagementClientContext.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-dns"; -const packageVersion = "4.0.0"; +const packageVersion = "4.1.0"; export class DnsManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the DnsManagementClient 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 Specifies the Azure subscription ID, which uniquely identifies the * Microsoft Azure subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DnsManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DnsManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } diff --git a/sdk/domainservices/arm-domainservices/README.md b/sdk/domainservices/arm-domainservices/README.md index 40c93925e577..49b77e9cb854 100644 --- a/sdk/domainservices/arm-domainservices/README.md +++ b/sdk/domainservices/arm-domainservices/README.md @@ -1,89 +1,100 @@ ## Azure DomainservicesManagementClient SDK for JavaScript -This package contains an isomorphic SDK for DomainservicesManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for DomainservicesManagementClient. ### 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-domainservices +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-domainservices` 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-domainservices @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 domainServiceOperations as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. -``` -npm install @azure/ms-rest-nodeauth -``` +#### nodejs - Authentication, client creation, and list domainServiceOperations 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 { DomainservicesManagementClient, DomainservicesManagementModels, DomainservicesManagementMappers } from "@azure/arm-domainservices"; +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { DomainservicesManagementClient } = require("@azure/arm-domainservices"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new DomainservicesManagementClient(creds, subscriptionId); - client.domainServiceOperations.list().then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new DomainservicesManagementClient(creds, subscriptionId); + +client.domainServiceOperations.list().then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list domainServiceOperations as an example written in JavaScript. - -##### Install @azure/ms-rest-browserauth +#### browser - Authentication, client creation, and list domainServiceOperations as an example written in JavaScript. -``` -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-domainservices sample - - + @@ -95,5 +106,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fdomainservices%2Farm-domainservices%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/domainservices/arm-domainservices/README.png) diff --git a/sdk/domainservices/arm-domainservices/package.json b/sdk/domainservices/arm-domainservices/package.json index 6ed59f03b209..26d00ac128ec 100644 --- a/sdk/domainservices/arm-domainservices/package.json +++ b/sdk/domainservices/arm-domainservices/package.json @@ -2,10 +2,11 @@ "name": "@azure/arm-domainservices", "author": "Microsoft Corporation", "description": "DomainservicesManagementClient Library with typescript type definitions for node.js and browser.", - "version": "3.1.0", + "version": "3.2.0", "dependencies": { - "@azure/ms-rest-azure-js": "^1.1.0", - "@azure/ms-rest-js": "^1.1.0", + "@azure/ms-rest-azure-js": "^1.4.0", + "@azure/ms-rest-js": "^1.11.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.9.3" }, "keywords": [ @@ -20,7 +21,7 @@ "module": "./esm/domainservicesManagementClient.js", "types": "./esm/domainservicesManagementClient.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/domainservices/arm-domainservices/src/domainservicesManagementClient.ts b/sdk/domainservices/arm-domainservices/src/domainservicesManagementClient.ts index 99e64b1dd67b..0bb81ecbda52 100644 --- a/sdk/domainservices/arm-domainservices/src/domainservicesManagementClient.ts +++ b/sdk/domainservices/arm-domainservices/src/domainservicesManagementClient.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 DomainservicesManagementClient extends DomainservicesManagementClientConte /** * Initializes a new instance of the DomainservicesManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Gets subscription credentials which uniquely identify the Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DomainservicesManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DomainservicesManagementClientOptions) { super(credentials, subscriptionId, options); this.domainServiceOperations = new operations.DomainServiceOperations(this); this.domainServices = new operations.DomainServices(this); diff --git a/sdk/domainservices/arm-domainservices/src/domainservicesManagementClientContext.ts b/sdk/domainservices/arm-domainservices/src/domainservicesManagementClientContext.ts index 83b1b9c3eecd..70778dd9f58f 100644 --- a/sdk/domainservices/arm-domainservices/src/domainservicesManagementClientContext.ts +++ b/sdk/domainservices/arm-domainservices/src/domainservicesManagementClientContext.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-domainservices"; -const packageVersion = "0.1.0"; +const packageVersion = "3.2.0"; export class DomainservicesManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the DomainservicesManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId Gets subscription credentials which uniquely identify the Microsoft Azure * subscription. The subscription ID forms part of the URI for every service call. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.DomainservicesManagementClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.DomainservicesManagementClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); }