|
| 1 | +# AzureArcDataManagement client library for JavaScript |
| 2 | + |
| 3 | +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AzureArcDataManagement client. |
| 4 | + |
| 5 | +The AzureArcData management API provides a RESTful set of web APIs to manage Azure Data Services on Azure Arc Resources. |
| 6 | + |
| 7 | +[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/azurearcdata/arm-azurearcdata) | |
| 8 | +[Package (NPM)](https://www.npmjs.com/package/@azure/arm-azurearcdata) | |
| 9 | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-azurearcdata?view=azure-node-preview) | |
| 10 | +[Samples](https://github.com/Azure-Samples/azure-samples-js-management) |
| 11 | + |
| 12 | +## Getting started |
| 13 | + |
| 14 | +### Currently supported environments |
| 15 | + |
| 16 | +- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) |
| 17 | +- Latest versions of Safari, Chrome, Edge and Firefox. |
| 18 | + |
| 19 | +See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. |
| 20 | + |
| 21 | +### Prerequisites |
| 22 | + |
| 23 | +- An [Azure subscription][azure_sub]. |
| 24 | + |
| 25 | +### Install the `@azure/arm-azurearcdata` package |
| 26 | + |
| 27 | +Install the AzureArcDataManagement client library for JavaScript with `npm`: |
| 28 | + |
| 29 | +```bash |
| 30 | +npm install @azure/arm-azurearcdata |
| 31 | +``` |
| 32 | + |
| 33 | +### Create and authenticate a `AzureArcDataManagementClient` |
| 34 | + |
| 35 | +To create a client object to access the AzureArcDataManagement API, you will need the `endpoint` of your AzureArcDataManagement resource and a `credential`. The AzureArcDataManagement client can use Azure Active Directory credentials to authenticate. |
| 36 | +You can find the endpoint for your AzureArcDataManagement resource in the [Azure Portal][azure_portal]. |
| 37 | + |
| 38 | +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). |
| 39 | + |
| 40 | +To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: |
| 41 | + |
| 42 | +```bash |
| 43 | +npm install @azure/identity |
| 44 | +``` |
| 45 | + |
| 46 | +You will also need to **register a new AAD application and grant access to AzureArcDataManagement** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). |
| 47 | +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`. |
| 48 | + |
| 49 | +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). |
| 50 | + |
| 51 | +```javascript |
| 52 | +const { AzureArcDataManagementClient } = require("@azure/arm-azurearcdata"); |
| 53 | +const { DefaultAzureCredential } = require("@azure/identity"); |
| 54 | +// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. |
| 55 | + |
| 56 | +const subscriptionId = "00000000-0000-0000-0000-000000000000"; |
| 57 | +const client = new AzureArcDataManagementClient(new DefaultAzureCredential(), subscriptionId); |
| 58 | + |
| 59 | +// For client-side applications running in the browser, use this code instead: |
| 60 | +// const credential = new InteractiveBrowserCredential({ |
| 61 | +// tenantId: "<YOUR_TENANT_ID>", |
| 62 | +// clientId: "<YOUR_CLIENT_ID>" |
| 63 | +// }); |
| 64 | +// const client = new AzureArcDataManagementClient(credential, subscriptionId); |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | +### JavaScript Bundle |
| 69 | +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). |
| 70 | + |
| 71 | +## Key concepts |
| 72 | + |
| 73 | +### AzureArcDataManagementClient |
| 74 | + |
| 75 | +`AzureArcDataManagementClient` is the primary interface for developers using the AzureArcDataManagement client library. Explore the methods on this client object to understand the different features of the AzureArcDataManagement service that you can access. |
| 76 | + |
| 77 | +## Troubleshooting |
| 78 | + |
| 79 | +### Logging |
| 80 | + |
| 81 | +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`: |
| 82 | + |
| 83 | +```javascript |
| 84 | +const { setLogLevel } = require("@azure/logger"); |
| 85 | +setLogLevel("info"); |
| 86 | +``` |
| 87 | + |
| 88 | +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). |
| 89 | + |
| 90 | +## Next steps |
| 91 | + |
| 92 | +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. |
| 93 | + |
| 94 | +## Contributing |
| 95 | + |
| 96 | +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. |
| 97 | + |
| 98 | +## Related projects |
| 99 | + |
| 100 | +- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | +[azure_cli]: https://docs.microsoft.com/cli/azure |
| 105 | +[azure_sub]: https://azure.microsoft.com/free/ |
| 106 | +[azure_sub]: https://azure.microsoft.com/free/ |
| 107 | +[azure_portal]: https://portal.azure.com |
| 108 | +[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity |
| 109 | +[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential |
0 commit comments