|
1 | 1 | ## Azure SynapseManagementClient SDK for JavaScript
|
2 | 2 |
|
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. |
4 | 4 |
|
5 | 5 | ### Currently supported environments
|
6 | 6 |
|
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. |
9 | 9 |
|
10 |
| -### How to Install |
| 10 | +### Prerequisites |
11 | 11 |
|
| 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: |
12 | 21 | ```bash
|
13 |
| -npm install @azure/arm-synapse |
| 22 | +npm install --save @azure/arm-synapse @azure/identity |
14 | 23 | ```
|
| 24 | +> **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. |
| 25 | +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. |
15 | 26 |
|
16 | 27 | ### How to use
|
17 | 28 |
|
18 |
| -#### nodejs - client creation and get bigDataPools as an example written in TypeScript. |
| 29 | +- If you are writing a client side browser application, |
| 30 | + - 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. |
| 31 | + - 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. |
| 32 | +- If you are writing a server side application, |
| 33 | + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) |
| 34 | + - Complete the set up steps required by the credential if any. |
| 35 | + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. |
19 | 36 |
|
20 |
| -##### Install @azure/ms-rest-nodeauth |
21 |
| - |
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 |
| -``` |
| 37 | +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. |
| 38 | +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. |
| 39 | +#### nodejs - Authentication, client creation, and get bigDataPools as an example written in JavaScript. |
26 | 40 |
|
27 | 41 | ##### Sample code
|
28 | 42 |
|
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"); |
| 43 | +```javascript |
| 44 | +const { DefaultAzureCredential } = require("@azure/identity"); |
32 | 45 | const { SynapseManagementClient } = require("@azure/arm-synapse");
|
33 | 46 | const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];
|
34 | 47 |
|
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 |
| - }); |
| 48 | +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples |
| 49 | +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. |
| 50 | +const creds = new DefaultAzureCredential(); |
| 51 | +const client = new SynapseManagementClient(creds, subscriptionId); |
| 52 | +const resourceGroupName = "testresourceGroupName"; |
| 53 | +const workspaceName = "testworkspaceName"; |
| 54 | +const bigDataPoolName = "testbigDataPoolName"; |
| 55 | +client.bigDataPools.get(resourceGroupName, workspaceName, bigDataPoolName).then((result) => { |
| 56 | + console.log("The result is:"); |
| 57 | + console.log(result); |
44 | 58 | }).catch((err) => {
|
| 59 | + console.log("An error occurred:"); |
45 | 60 | console.error(err);
|
46 | 61 | });
|
47 | 62 | ```
|
48 | 63 |
|
49 |
| -#### browser - Authentication, client creation and get bigDataPools as an example written in JavaScript. |
| 64 | +#### browser - Authentication, client creation, and get bigDataPools as an example written in JavaScript. |
50 | 65 |
|
51 |
| -##### Install @azure/ms-rest-browserauth |
52 |
| - |
53 |
| -```bash |
54 |
| -npm install @azure/ms-rest-browserauth |
55 |
| -``` |
| 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. |
56 | 69 |
|
57 | 70 | ##### Sample code
|
58 | 71 |
|
59 |
| -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. |
60 |
| - |
61 | 72 | - index.html
|
| 73 | + |
62 | 74 | ```html
|
63 | 75 | <!DOCTYPE html>
|
64 | 76 | <html lang="en">
|
65 | 77 | <head>
|
66 | 78 | <title>@azure/arm-synapse sample</title>
|
67 |
| - <script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script> |
68 | 79 | <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> |
| 80 | + <script src="node_modules/@azure/identity/dist/index.js"></script> |
70 | 81 | <script src="node_modules/@azure/arm-synapse/dist/arm-synapse.js"></script>
|
71 | 82 | <script type="text/javascript">
|
72 | 83 | const subscriptionId = "<Subscription_Id>";
|
73 |
| - 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 | + { |
74 | 88 | clientId: "<client id for your Azure AD app>",
|
75 | 89 | tenant: "<optional tenant for your organization>"
|
76 | 90 | });
|
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 |
| - }); |
| 91 | + const client = new Azure.ArmSynapse.SynapseManagementClient(creds, subscriptionId); |
| 92 | + const resourceGroupName = "testresourceGroupName"; |
| 93 | + const workspaceName = "testworkspaceName"; |
| 94 | + const bigDataPoolName = "testbigDataPoolName"; |
| 95 | + client.bigDataPools.get(resourceGroupName, workspaceName, bigDataPoolName).then((result) => { |
| 96 | + console.log("The result is:"); |
| 97 | + console.log(result); |
| 98 | + }).catch((err) => { |
| 99 | + console.log("An error occurred:"); |
| 100 | + console.error(err); |
93 | 101 | });
|
94 | 102 | </script>
|
95 | 103 | </head>
|
|
0 commit comments