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.
- Scan your data into your catalog
- Examine your data
- Extract schemas from your data
Please rely heavily on the service's documentation and our Rest client docs to use this library
Key links:
- You must have an Azure subscription and a Purview to use this package.
Follow these instructions to create your Purview resource
Install the Azure Purview Scanning client library for JavaScript with npm:
npm install @azure-rest/purview-scanningTo use an Azure Active Directory (AAD) token credential, provide an instance of the desired credential type obtained from the @azure/identity library.
To authenticate with AAD, you must first npm install @azure/identity and
enable AAD authentication on your Purview resource
After setup, you can choose which type of credential from @azure/identity to use.
As an example, DefaultAzureCredential
can be used to authenticate the client:
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
Use the returned token credential to authenticate the client:
import PurviewScanning from "@azure-rest/purview-scanning";
import { DefaultAzureCredential } from "@azure/identity";
const client = PurviewScanning(
"https://.purview.azure.com" ,
new DefaultAzureCredential()
);This client is one of our Rest clients. We highly recommend you read how to use a Rest client here.
The following section shows you how to initialize and authenticate your client, then list all of your data sources.
import PurviewScanning, { paginate, DataSourceOutput, PagedAsyncIterableIterator, PageSettings, isUnexpected } from "@azure-rest/purview-scanning";
import { DefaultAzureCredential } from "@azure/identity";
async function main(): Promise<void> {
console.log("== List dataSources ==");
const client = PurviewScanning(
"https://.purview.azure.com" ,
new DefaultAzureCredential()
);
const dataSources = await client.path("/datasources").get();
if (isUnexpected(dataSources)) {
throw dataSources.body.error;
}
const iter = paginate(client, dataSources);
const items: DataSourceOutput[] = [];
for await (const item of <PagedAsyncIterableIterator<DataSourceOutput, (DataSourceOutput)[], PageSettings>>iter) {
items.push(item);
}
console.log(items?.map((ds) => ds.name).join("\n"));
}
main().catch(console.error);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:
import { setLogLevel } from "@azure/logger";
setLogLevel("info");For more detailed instructions on how to enable logs, you can look at the @azure/logger package docs.
If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.