Skip to content

Commit 719cb86

Browse files
authored
90 rp identity support (Azure#16296)
1 parent 4dbf054 commit 719cb86

File tree

16 files changed

+327
-235
lines changed

16 files changed

+327
-235
lines changed

sdk/synapse/arm-synapse/README.md

Lines changed: 61 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,105 @@
11
## Azure SynapseManagementClient SDK for JavaScript
22

3-
This package contains an isomorphic SDK for SynapseManagementClient.
3+
This package contains an isomorphic SDK (runs both in Node.js and in browsers) for SynapseManagementClient.
44

55
### Currently supported environments
66

7-
- Node.js version 6.x.x or higher
8-
- Browser JavaScript
7+
- [LTS versions of Node.js](https://nodejs.org/about/releases/)
8+
- Latest versions of Safari, Chrome, Edge, and Firefox.
99

10-
### How to Install
10+
### Prerequisites
1111

12+
You must have an [Azure subscription](https://azure.microsoft.com/free/).
13+
14+
### How to install
15+
16+
To use this SDK in your project, you will need to install two packages.
17+
- `@azure/arm-synapse` that contains the client.
18+
- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory.
19+
20+
Install both packages using the below command:
1221
```bash
13-
npm install @azure/arm-synapse
22+
npm install --save @azure/arm-synapse @azure/identity
1423
```
1524

25+
> **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.
26+
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.
27+
1628
### How to use
1729

18-
#### nodejs - client creation and get bigDataPools as an example written in TypeScript.
30+
- If you are writing a client side browser application,
31+
- 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.
32+
- 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.
33+
- If you are writing a server side application,
34+
- [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples)
35+
- Complete the set up steps required by the credential if any.
36+
- Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below.
1937

20-
##### Install @azure/ms-rest-nodeauth
38+
In the below samples, we pass the credential and the Azure subscription id to instantiate the client.
39+
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.
2140

22-
- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`.
23-
```bash
24-
npm install @azure/ms-rest-nodeauth@"^3.0.0"
25-
```
41+
#### nodejs - Authentication, client creation, and get bigDataPools as an example written in JavaScript.
2642

2743
##### Sample code
2844

29-
While the below sample uses the interactive login, other authentication options can be found in the [README.md file of @azure/ms-rest-nodeauth](https://www.npmjs.com/package/@azure/ms-rest-nodeauth) package
30-
```typescript
31-
const msRestNodeAuth = require("@azure/ms-rest-nodeauth");
45+
```javascript
46+
const { DefaultAzureCredential } = require("@azure/identity");
3247
const { SynapseManagementClient } = require("@azure/arm-synapse");
3348
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];
3449

35-
msRestNodeAuth.interactiveLogin().then((creds) => {
36-
const client = new SynapseManagementClient(creds, subscriptionId);
37-
const resourceGroupName = "testresourceGroupName";
38-
const workspaceName = "testworkspaceName";
39-
const bigDataPoolName = "testbigDataPoolName";
40-
client.bigDataPools.get(resourceGroupName, workspaceName, bigDataPoolName).then((result) => {
41-
console.log("The result is:");
42-
console.log(result);
43-
});
50+
// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples
51+
// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead.
52+
const creds = new DefaultAzureCredential();
53+
const client = new SynapseManagementClient(creds, subscriptionId);
54+
const resourceGroupName = "testresourceGroupName";
55+
const workspaceName = "testworkspaceName";
56+
const bigDataPoolName = "testbigDataPoolName";
57+
client.bigDataPools.get(resourceGroupName, workspaceName, bigDataPoolName).then((result) => {
58+
console.log("The result is:");
59+
console.log(result);
4460
}).catch((err) => {
61+
console.log("An error occurred:");
4562
console.error(err);
4663
});
4764
```
4865

49-
#### browser - Authentication, client creation and get bigDataPools as an example written in JavaScript.
66+
#### browser - Authentication, client creation, and get bigDataPools as an example written in JavaScript.
5067

51-
##### Install @azure/ms-rest-browserauth
52-
53-
```bash
54-
npm install @azure/ms-rest-browserauth
55-
```
68+
In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser.
69+
- 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.
70+
- Note down the client Id from the previous step and use it in the browser sample below.
5671

5772
##### Sample code
5873

59-
See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.
60-
6174
- index.html
75+
6276
```html
6377
<!DOCTYPE html>
6478
<html lang="en">
6579
<head>
6680
<title>@azure/arm-synapse sample</title>
67-
<script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
6881
<script src="node_modules/@azure/ms-rest-azure-js/dist/msRestAzure.js"></script>
69-
<script src="node_modules/@azure/ms-rest-browserauth/dist/msAuth.js"></script>
82+
<script src="node_modules/@azure/identity/dist/index.js"></script>
7083
<script src="node_modules/@azure/arm-synapse/dist/arm-synapse.js"></script>
7184
<script type="text/javascript">
7285
const subscriptionId = "<Subscription_Id>";
73-
const authManager = new msAuth.AuthManager({
86+
// Create credentials using the `@azure/identity` package.
87+
// Please note that you can also use credentials from the `@azure/ms-rest-browserauth` package instead.
88+
const credential = new InteractiveBrowserCredential(
89+
{
7490
clientId: "<client id for your Azure AD app>",
75-
tenant: "<optional tenant for your organization>"
91+
tenantId: "<optional tenant for your organization>"
7692
});
77-
authManager.finalizeLogin().then((res) => {
78-
if (!res.isLoggedIn) {
79-
// may cause redirects
80-
authManager.login();
81-
}
82-
const client = new Azure.ArmSynapse.SynapseManagementClient(res.creds, subscriptionId);
83-
const resourceGroupName = "testresourceGroupName";
84-
const workspaceName = "testworkspaceName";
85-
const bigDataPoolName = "testbigDataPoolName";
86-
client.bigDataPools.get(resourceGroupName, workspaceName, bigDataPoolName).then((result) => {
87-
console.log("The result is:");
88-
console.log(result);
89-
}).catch((err) => {
90-
console.log("An error occurred:");
91-
console.error(err);
92-
});
93+
const client = new Azure.ArmSynapse.SynapseManagementClient(creds, subscriptionId);
94+
const resourceGroupName = "testresourceGroupName";
95+
const workspaceName = "testworkspaceName";
96+
const bigDataPoolName = "testbigDataPoolName";
97+
client.bigDataPools.get(resourceGroupName, workspaceName, bigDataPoolName).then((result) => {
98+
console.log("The result is:");
99+
console.log(result);
100+
}).catch((err) => {
101+
console.log("An error occurred:");
102+
console.error(err);
93103
});
94104
</script>
95105
</head>

sdk/synapse/arm-synapse/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
"name": "@azure/arm-synapse",
33
"author": "Microsoft Corporation",
44
"description": "SynapseManagementClient Library with typescript type definitions for node.js and browser.",
5-
"version": "5.1.0",
5+
"version": "5.2.0",
66
"dependencies": {
7-
"@azure/ms-rest-azure-js": "^2.0.1",
8-
"@azure/ms-rest-js": "^2.0.4",
7+
"@azure/ms-rest-azure-js": "^2.1.0",
8+
"@azure/ms-rest-js": "^2.2.0",
9+
"@azure/core-auth": "^1.1.4",
910
"tslib": "^1.10.0"
1011
},
1112
"keywords": [
@@ -20,7 +21,7 @@
2021
"module": "./esm/synapseManagementClient.js",
2122
"types": "./esm/synapseManagementClient.d.ts",
2223
"devDependencies": {
23-
"typescript": "^3.5.3",
24+
"typescript": "^3.6.0",
2425
"rollup": "^1.18.0",
2526
"rollup-plugin-node-resolve": "^5.2.0",
2627
"rollup-plugin-sourcemaps": "^0.4.2",

sdk/synapse/arm-synapse/src/synapseManagementClient.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
import * as msRest from "@azure/ms-rest-js";
11+
import { TokenCredential } from "@azure/core-auth";
1112
import * as Models from "./models";
1213
import * as Mappers from "./models/mappers";
1314
import * as operations from "./operations";
@@ -80,11 +81,16 @@ class SynapseManagementClient extends SynapseManagementClientContext {
8081

8182
/**
8283
* Initializes a new instance of the SynapseManagementClient class.
83-
* @param credentials Credentials needed for the client to connect to Azure.
84+
* @param credentials Credentials needed for the client to connect to Azure. Credentials
85+
* implementing the TokenCredential interface from the @azure/identity package are recommended. For
86+
* more information about these credentials, see
87+
* {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the
88+
* ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and
89+
* @azure/ms-rest-browserauth are also supported.
8490
* @param subscriptionId The ID of the target subscription.
8591
* @param [options] The parameter options
8692
*/
87-
constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.SynapseManagementClientOptions) {
93+
constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.SynapseManagementClientOptions) {
8894
super(credentials, subscriptionId, options);
8995
this.bigDataPools = new operations.BigDataPools(this);
9096
this.operations = new operations.Operations(this);

sdk/synapse/arm-synapse/src/synapseManagementClientContext.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,29 @@
99

1010
import * as Models from "./models";
1111
import * as msRest from "@azure/ms-rest-js";
12+
import { TokenCredential } from "@azure/core-auth";
1213
import * as msRestAzure from "@azure/ms-rest-azure-js";
1314

1415
const packageName = "@azure/arm-synapse";
15-
const packageVersion = "5.1.0";
16+
const packageVersion = "5.2.0";
1617

1718
export class SynapseManagementClientContext extends msRestAzure.AzureServiceClient {
18-
credentials: msRest.ServiceClientCredentials;
19+
credentials: msRest.ServiceClientCredentials | TokenCredential;
1920
subscriptionId: string;
2021
apiVersion?: string;
2122

2223
/**
2324
* Initializes a new instance of the SynapseManagementClient class.
24-
* @param credentials Credentials needed for the client to connect to Azure.
25+
* @param credentials Credentials needed for the client to connect to Azure. Credentials
26+
* implementing the TokenCredential interface from the @azure/identity package are recommended. For
27+
* more information about these credentials, see
28+
* {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the
29+
* ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and
30+
* @azure/ms-rest-browserauth are also supported.
2531
* @param subscriptionId The ID of the target subscription.
2632
* @param [options] The parameter options
2733
*/
28-
constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.SynapseManagementClientOptions) {
34+
constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.SynapseManagementClientOptions) {
2935
if (credentials == undefined) {
3036
throw new Error('\'credentials\' cannot be null.');
3137
}

sdk/timeseriesinsights/arm-timeseriesinsights/README.md

Lines changed: 57 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,100 @@
11
## Azure TimeSeriesInsightsClient SDK for JavaScript
22

3-
This package contains an isomorphic SDK for TimeSeriesInsightsClient.
3+
This package contains an isomorphic SDK (runs both in Node.js and in browsers) for TimeSeriesInsightsClient.
44

55
### Currently supported environments
66

7-
- Node.js version 6.x.x or higher
8-
- Browser JavaScript
7+
- [LTS versions of Node.js](https://nodejs.org/about/releases/)
8+
- Latest versions of Safari, Chrome, Edge, and Firefox.
99

10-
### How to Install
10+
### Prerequisites
1111

12+
You must have an [Azure subscription](https://azure.microsoft.com/free/).
13+
14+
### How to install
15+
16+
To use this SDK in your project, you will need to install two packages.
17+
- `@azure/arm-timeseriesinsights` that contains the client.
18+
- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory.
19+
20+
Install both packages using the below command:
1221
```bash
13-
npm install @azure/arm-timeseriesinsights
22+
npm install --save @azure/arm-timeseriesinsights @azure/identity
1423
```
1524

25+
> **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.
26+
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.
27+
1628
### How to use
1729

18-
#### nodejs - Authentication, client creation and list operations as an example written in TypeScript.
30+
- If you are writing a client side browser application,
31+
- 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.
32+
- 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.
33+
- If you are writing a server side application,
34+
- [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples)
35+
- Complete the set up steps required by the credential if any.
36+
- Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below.
1937

20-
##### Install @azure/ms-rest-nodeauth
38+
In the below samples, we pass the credential and the Azure subscription id to instantiate the client.
39+
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.
2140

22-
- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`.
23-
```bash
24-
npm install @azure/ms-rest-nodeauth@"^3.0.0"
25-
```
41+
#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript.
2642

2743
##### Sample code
2844

29-
```typescript
30-
import * as msRest from "@azure/ms-rest-js";
31-
import * as msRestAzure from "@azure/ms-rest-azure-js";
32-
import * as msRestNodeAuth from "@azure/ms-rest-nodeauth";
33-
import { TimeSeriesInsightsClient, TimeSeriesInsightsModels, TimeSeriesInsightsMappers } from "@azure/arm-timeseriesinsights";
45+
```javascript
46+
const { DefaultAzureCredential } = require("@azure/identity");
47+
const { TimeSeriesInsightsClient } = require("@azure/arm-timeseriesinsights");
3448
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];
3549

36-
msRestNodeAuth.interactiveLogin().then((creds) => {
37-
const client = new TimeSeriesInsightsClient(creds, subscriptionId);
38-
client.operations.list().then((result) => {
39-
console.log("The result is:");
40-
console.log(result);
41-
});
50+
// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples
51+
// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead.
52+
const creds = new DefaultAzureCredential();
53+
const client = new TimeSeriesInsightsClient(creds, subscriptionId);
54+
55+
client.operations.list().then((result) => {
56+
console.log("The result is:");
57+
console.log(result);
4258
}).catch((err) => {
59+
console.log("An error occurred:");
4360
console.error(err);
4461
});
4562
```
4663

47-
#### browser - Authentication, client creation and list operations as an example written in JavaScript.
48-
49-
##### Install @azure/ms-rest-browserauth
64+
#### browser - Authentication, client creation, and list operations as an example written in JavaScript.
5065

51-
```bash
52-
npm install @azure/ms-rest-browserauth
53-
```
66+
In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser.
67+
- 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.
68+
- Note down the client Id from the previous step and use it in the browser sample below.
5469

5570
##### Sample code
5671

57-
See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.
58-
5972
- index.html
73+
6074
```html
6175
<!DOCTYPE html>
6276
<html lang="en">
6377
<head>
6478
<title>@azure/arm-timeseriesinsights sample</title>
65-
<script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
6679
<script src="node_modules/@azure/ms-rest-azure-js/dist/msRestAzure.js"></script>
67-
<script src="node_modules/@azure/ms-rest-browserauth/dist/msAuth.js"></script>
80+
<script src="node_modules/@azure/identity/dist/index.js"></script>
6881
<script src="node_modules/@azure/arm-timeseriesinsights/dist/arm-timeseriesinsights.js"></script>
6982
<script type="text/javascript">
7083
const subscriptionId = "<Subscription_Id>";
71-
const authManager = new msAuth.AuthManager({
84+
// Create credentials using the `@azure/identity` package.
85+
// Please note that you can also use credentials from the `@azure/ms-rest-browserauth` package instead.
86+
const credential = new InteractiveBrowserCredential(
87+
{
7288
clientId: "<client id for your Azure AD app>",
73-
tenant: "<optional tenant for your organization>"
89+
tenantId: "<optional tenant for your organization>"
7490
});
75-
authManager.finalizeLogin().then((res) => {
76-
if (!res.isLoggedIn) {
77-
// may cause redirects
78-
authManager.login();
79-
}
80-
const client = new Azure.ArmTimeseriesinsights.TimeSeriesInsightsClient(res.creds, subscriptionId);
81-
client.operations.list().then((result) => {
82-
console.log("The result is:");
83-
console.log(result);
84-
}).catch((err) => {
85-
console.log("An error occurred:");
86-
console.error(err);
87-
});
91+
const client = new Azure.ArmTimeseriesinsights.TimeSeriesInsightsClient(creds, subscriptionId);
92+
client.operations.list().then((result) => {
93+
console.log("The result is:");
94+
console.log(result);
95+
}).catch((err) => {
96+
console.log("An error occurred:");
97+
console.error(err);
8898
});
8999
</script>
90100
</head>

0 commit comments

Comments
 (0)