|
1 | | -## Azure AzureMLWebServicesManagementClient SDK for JavaScript |
| 1 | +# Azure ML Web Services Management client library for JavaScript |
2 | 2 |
|
3 | | -This package contains an isomorphic SDK for AzureMLWebServicesManagementClient. |
| 3 | +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure ML Web Services Management client. |
| 4 | + |
| 5 | +These APIs allow end users to operate on Azure Machine Learning Web Services resources. They support the following operations:<ul><li>Create or update a web service</li><li>Get a web service</li><li>Patch a web service</li><li>Delete a web service</li><li>Get All Web Services in a Resource Group </li><li>Get All Web Services in a Subscription</li><li>Get Web Services Keys</li></ul> |
| 6 | + |
| 7 | +[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/machinelearning/arm-webservices) | |
| 8 | +[Package (NPM)](https://www.npmjs.com/package/@azure/arm-webservices) | |
| 9 | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-webservices) | |
| 10 | +[Samples](https://github.com/Azure-Samples/azure-samples-js-management) |
| 11 | + |
| 12 | +## Getting started |
4 | 13 |
|
5 | 14 | ### Currently supported environments |
6 | 15 |
|
7 | 16 | - [LTS versions of Node.js](https://nodejs.org/about/releases/) |
8 | | -- Latest versions of Safari, Chrome, Edge, and Firefox. |
| 17 | +- Latest versions of Safari, Chrome, Edge and Firefox. |
9 | 18 |
|
10 | | -### How to Install |
| 19 | +### Prerequisites |
11 | 20 |
|
12 | | -``` |
| 21 | +- An [Azure subscription][azure_sub]. |
| 22 | + |
| 23 | +### Install the `@azure/arm-webservices` package |
| 24 | + |
| 25 | +Install the Azure ML Web Services Management client library for JavaScript with `npm`: |
| 26 | + |
| 27 | +```bash |
13 | 28 | npm install @azure/arm-webservices |
14 | 29 | ``` |
15 | 30 |
|
16 | | -### How to use |
| 31 | +### Create and authenticate a `AzureMLWebServicesManagementClient` |
17 | 32 |
|
18 | | -#### nodejs - Authentication, client creation and list operations as an example written in TypeScript. |
| 33 | +To create a client object to access the Azure ML Web Services Management API, you will need the `endpoint` of your Azure ML Web Services Management resource and a `credential`. The Azure ML Web Services Management client can use Azure Active Directory credentials to authenticate. |
| 34 | +You can find the endpoint for your Azure ML Web Services Management resource in the [Azure Portal][azure_portal]. |
19 | 35 |
|
20 | | -##### Install @azure/ms-rest-nodeauth |
| 36 | +You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). |
21 | 37 |
|
22 | | -``` |
23 | | -npm install @azure/ms-rest-nodeauth |
24 | | -``` |
| 38 | +To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: |
25 | 39 |
|
26 | | -##### Sample code |
27 | | - |
28 | | -```ts |
29 | | -import * as msRest from "@azure/ms-rest-js"; |
30 | | -import * as msRestAzure from "@azure/ms-rest-azure-js"; |
31 | | -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; |
32 | | -import { AzureMLWebServicesManagementClient, AzureMLWebServicesManagementModels, AzureMLWebServicesManagementMappers } from "@azure/arm-webservices"; |
33 | | -const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; |
34 | | - |
35 | | -msRestNodeAuth.interactiveLogin().then((creds) => { |
36 | | - const client = new AzureMLWebServicesManagementClient(creds, subscriptionId); |
37 | | - client.operations.list().then((result) => { |
38 | | - console.log("The result is:"); |
39 | | - console.log(result); |
40 | | - }); |
41 | | -}).catch((err) => { |
42 | | - console.error(err); |
43 | | -}); |
| 40 | +```bash |
| 41 | +npm install @azure/identity |
44 | 42 | ``` |
45 | 43 |
|
46 | | -#### browser - Authentication, client creation and list operations as an example written in JavaScript. |
| 44 | +You will also need to **register a new AAD application and grant access to Azure ML Web Services Management** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). |
| 45 | +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`. |
47 | 46 |
|
48 | | -##### Install @azure/ms-rest-browserauth |
| 47 | +For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). |
49 | 48 |
|
| 49 | +```javascript |
| 50 | +const { AzureMLWebServicesManagementClient } = require("@azure/arm-webservices"); |
| 51 | +const { DefaultAzureCredential } = require("@azure/identity"); |
| 52 | +const subscriptionId = "00000000-0000-0000-0000-000000000000"; |
| 53 | +const client = new AzureMLWebServicesManagementClient(new DefaultAzureCredential(), subscriptionId); |
50 | 54 | ``` |
51 | | -npm install @azure/ms-rest-browserauth |
52 | | -``` |
53 | 55 |
|
54 | | -##### Sample code |
55 | | - |
56 | | -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. |
57 | | - |
58 | | -- index.html |
59 | | -```html |
60 | | -<!DOCTYPE html> |
61 | | -<html lang="en"> |
62 | | - <head> |
63 | | - <title>@azure/arm-webservices sample</title> |
64 | | - <script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script> |
65 | | - <script src="node_modules/@azure/ms-rest-azure-js/dist/msRestAzure.js"></script> |
66 | | - <script src="node_modules/@azure/ms-rest-browserauth/dist/msAuth.js"></script> |
67 | | - <script src="node_modules/@azure/arm-webservices/dist/arm-webservices.js"></script> |
68 | | - <script type="text/javascript"> |
69 | | - const subscriptionId = "<Subscription_Id>"; |
70 | | - const authManager = new msAuth.AuthManager({ |
71 | | - clientId: "<client id for your Azure AD app>", |
72 | | - tenant: "<optional tenant for your organization>" |
73 | | - }); |
74 | | - authManager.finalizeLogin().then((res) => { |
75 | | - if (!res.isLoggedIn) { |
76 | | - // may cause redirects |
77 | | - authManager.login(); |
78 | | - } |
79 | | - const client = new Azure.ArmWebservices.AzureMLWebServicesManagementClient(res.creds, subscriptionId); |
80 | | - client.operations.list().then((result) => { |
81 | | - console.log("The result is:"); |
82 | | - console.log(result); |
83 | | - }).catch((err) => { |
84 | | - console.log("An error occurred:"); |
85 | | - console.error(err); |
86 | | - }); |
87 | | - }); |
88 | | - </script> |
89 | | - </head> |
90 | | - <body></body> |
91 | | -</html> |
| 56 | + |
| 57 | +### JavaScript Bundle |
| 58 | +To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). |
| 59 | + |
| 60 | +## Key concepts |
| 61 | + |
| 62 | +### AzureMLWebServicesManagementClient |
| 63 | + |
| 64 | +`AzureMLWebServicesManagementClient` is the primary interface for developers using the Azure ML Web Services Management client library. Explore the methods on this client object to understand the different features of the Azure ML Web Services Management service that you can access. |
| 65 | + |
| 66 | +## Troubleshooting |
| 67 | + |
| 68 | +### Logging |
| 69 | + |
| 70 | +Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: |
| 71 | + |
| 72 | +```javascript |
| 73 | +const { setLogLevel } = require("@azure/logger"); |
| 74 | +setLogLevel("info"); |
92 | 75 | ``` |
93 | 76 |
|
94 | | -## Related projects |
| 77 | +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). |
95 | 78 |
|
96 | | -- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) |
| 79 | +## Next steps |
97 | 80 |
|
| 81 | +Please take a look at the [samples](https://github.com/Azure-Samples/azure-samples-js-management) directory for detailed examples on how to use this library. |
| 82 | + |
| 83 | +## Contributing |
| 84 | + |
| 85 | +If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code. |
| 86 | + |
| 87 | +## Related projects |
| 88 | + |
| 89 | +- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) |
98 | 90 |
|
99 | 91 |  |
| 92 | + |
| 93 | +[azure_cli]: https://docs.microsoft.com/cli/azure |
| 94 | +[azure_sub]: https://azure.microsoft.com/free/ |
| 95 | +[azure_sub]: https://azure.microsoft.com/free/ |
| 96 | +[azure_portal]: https://portal.azure.com |
| 97 | +[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity |
| 98 | +[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential |
0 commit comments