|
| 1 | +# Azure Purview Scanning Rest-Level client library for JavaScript |
| 2 | + |
| 3 | +Azure Purview Scanning is a fully managed cloud service whose users can scan your data into your data estate (also known as your **catalog**). Scanning is a process by which the catalog connects directly to a data source on a user-specified schedule. |
| 4 | + |
| 5 | +- Scan your data into your catalog |
| 6 | +- Examine your data |
| 7 | +- Extract schemas from your data |
| 8 | + |
| 9 | +**Please rely heavily on the [service's documentation][scanning_product_documentation] and our [Rest client docs][rest_client] to use this library** |
| 10 | + |
| 11 | +[Source code][source_code] | [Package (NPM)][scanning_npm] | [API reference documentation][scanning_ref_docs]| [Product documentation][scanning_product_documentation] |
| 12 | + |
| 13 | +## Getting started |
| 14 | + |
| 15 | +### Currently supported environments |
| 16 | + |
| 17 | +- Node.js version 14.x.x or higher |
| 18 | + |
| 19 | +### Prerequisites |
| 20 | + |
| 21 | +- You must have an [Azure subscription][azure_subscription] and a [Purview][purview_resource] to use this package. |
| 22 | + |
| 23 | +#### Create a Purview Resource |
| 24 | + |
| 25 | +Follow [these][purview_resource] instructions to create your Purview resource |
| 26 | + |
| 27 | +### Install the `@azure-rest/purview-scanning` package |
| 28 | + |
| 29 | +Install the Azure Purview Scanning client library for JavaScript with `npm`: |
| 30 | + |
| 31 | +```bash |
| 32 | +npm install @azure-rest/purview-scanning |
| 33 | +``` |
| 34 | + |
| 35 | +### Create and authenticate a `PurviewScanning` |
| 36 | + |
| 37 | +To use an [Azure Active Directory (AAD) token credential][authenticate_with_token], |
| 38 | +provide an instance of the desired credential type obtained from the |
| 39 | +[@azure/identity][azure_identity_credentials] library. |
| 40 | + |
| 41 | +To authenticate with AAD, you must first `npm` install [`@azure/identity`][azure_identity_npm] and |
| 42 | +[enable AAD authentication on your Purview resource][enable_aad] |
| 43 | + |
| 44 | +After setup, you can choose which type of [credential][azure_identity_credentials] from `@azure/identity` to use. |
| 45 | +As an example, [DefaultAzureCredential][default_azure_credential] |
| 46 | +can be used to authenticate the client: |
| 47 | + |
| 48 | +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: |
| 49 | +AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET |
| 50 | + |
| 51 | +Use the returned token credential to authenticate the client: |
| 52 | + |
| 53 | +```typescript |
| 54 | +import PurviewScanning from "@azure-rest/purview-scanning"; |
| 55 | +import { DefaultAzureCredential } from "@azure/identity"; |
| 56 | +const client = PurviewScanning( |
| 57 | + "https://<my-account-name>.scanning.purview.azure.com", |
| 58 | + new DefaultAzureCredential() |
| 59 | +); |
| 60 | +``` |
| 61 | + |
| 62 | +## Key concepts |
| 63 | + |
| 64 | +### Rest Client |
| 65 | + |
| 66 | +This client is one of our Rest clients. We highly recommend you read how to use a Rest client [here][rest_client]. |
| 67 | + |
| 68 | +## Examples |
| 69 | + |
| 70 | +The following section shows you how to initialize and authenticate your client, then list all of your data sources. |
| 71 | + |
| 72 | +- [List All Data Sources](#list-all-data-sources "List All Data Sources") |
| 73 | + |
| 74 | +### List All Data Sources |
| 75 | + |
| 76 | +```typescript |
| 77 | +import PurviewScanning from "@azure-rest/purview-scanning"; |
| 78 | +import { DefaultAzureCredential } from "@azure/identity"; |
| 79 | + |
| 80 | +async function main() { |
| 81 | + console.log("== List dataSources =="); |
| 82 | + const client = PurviewScanning( |
| 83 | + "https://<my-account-name>.scanning.purview.azure.com", |
| 84 | + new DefaultAzureCredential() |
| 85 | + ); |
| 86 | + |
| 87 | + const dataSources = await client.path("/datasources").get(); |
| 88 | + |
| 89 | + if (dataSources.status !== "200") { |
| 90 | + throw dataSources.body.error; |
| 91 | + } |
| 92 | + |
| 93 | + console.log(dataSources.body.value?.map((ds) => ds.name).join("\n")); |
| 94 | +} |
| 95 | + |
| 96 | +main().catch(console.error); |
| 97 | +``` |
| 98 | + |
| 99 | +## Troubleshooting |
| 100 | + |
| 101 | +### Logging |
| 102 | + |
| 103 | +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`: |
| 104 | + |
| 105 | +```javascript |
| 106 | +import { setLogLevel } from "@azure/logger"; |
| 107 | + |
| 108 | +setLogLevel("info"); |
| 109 | +``` |
| 110 | + |
| 111 | +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/master/sdk/core/logger). |
| 112 | + |
| 113 | +## Next steps |
| 114 | + |
| 115 | +## Contributing |
| 116 | + |
| 117 | +If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/master/CONTRIBUTING.md) to learn more about how to build and test the code. |
| 118 | + |
| 119 | +## Related projects |
| 120 | + |
| 121 | +- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | +<!-- LINKS --> |
| 126 | + |
| 127 | +[scanning_product_documentation]: https://azure.microsoft.com/services/purview/ |
| 128 | +[rest_client]: https://github.com/Azure/azure-sdk-for-js/blob/master/documentation/rest-clients.md |
| 129 | +[source_code]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/purview/purview-scanning-rest |
| 130 | +[scanning_npm]: https://www.npmjs.com/package/@azure-rest/purview-scanning |
| 131 | +[scanning_ref_docs]: https://azure.github.io/azure-sdk-for-js |
| 132 | +[azure_subscription]: https://azure.microsoft.com/free/ |
| 133 | +[purview_resource]: https://docs.microsoft.com/azure/purview/create-catalog-portal |
| 134 | +[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token |
| 135 | +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/identity/identity#credentials |
| 136 | +[azure_identity_npm]: https://www.npmjs.com/package/@azure/identity |
| 137 | +[enable_aad]: https://docs.microsoft.com/azure/purview/create-catalog-portal#add-a-security-principal-to-a-data-plane-role |
| 138 | +[default_azure_credential]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/identity/identity#defaultazurecredential |
0 commit comments