a28e8f0795
***NO_CI*** - apply the transformation - update samples' README |
||
---|---|---|
.. | ||
review | ||
samples/v1-beta | ||
samples-dev | ||
src | ||
swagger | ||
test/public | ||
CHANGELOG.md | ||
LICENSE | ||
README.md | ||
api-extractor.json | ||
assets.json | ||
eslint.config.mjs | ||
karma.conf.js | ||
package.json | ||
sample.env | ||
tsconfig.json |
README.md
Azure Purview Workflow Rest-Level client library for JavaScript
Workflows are automated, repeatable business processes that users can create within Microsoft Purview to validate and orchestrate CUD (create, update, delete) operations on their data entities. Enabling these processes allow organizations to track changes, enforce policy compliance, and ensure quality data across their data landscape.
Use the client library for Purview Workflow to:
- Manage workflows
- Submit user requests and monitor workflow runs
- View and respond to workflow tasks
For more details about how to use workflow, please refer to the service documentation
Getting started
Currently supported environments
Prerequisites
- You must have an Azure subscription and a Purview resource to use this package.
Create and authenticate a PurviewWorkflowClient
Since the Workflow service uses an Azure Active Directory (AAD) bearer token for authentication and identification, an email address should be encoded into the token to allow for notification when using Workflow. It is recommended that the Azure Identity library be used with a the UsernamePasswordCredential. Before using the Azure Identity library with Workflow, an application should be registered and used for the clientId passed to the UsernamePasswordCredential. Set the values of the client ID, tenant ID, username and password as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, USERNAME, PASSWORD
import PurviewWorkflow from "@azure-rest/purview-workflow";
import { UsernamePasswordCredential } from "@azure/identity";
import * as dotenv from "dotenv";
dotenv.config();
const endpoint = process.env["ENDPOINT"];
const tenantId = process.env["AZURE_TENANT_ID"];
const clientId = process.env["AZURE_CLIENT_ID"];
const username = process.env["USERNAME"];
const password = process.env["PASSWORD"];
const client = PurviewWorkflow(
endpoint,
new UsernamePasswordCredential(
tenantId,
clientId,
username,
password
)
);
Examples
The following section provides several code snippets covering some of the most common scenarios, including:
Submit user requests
import createPurviewWorkflowClient, {
SubmitUserRequestsParameters
} from "@azure-rest/purview-workflow";
import { UsernamePasswordCredential } from "@azure/identity";
import * as dotenv from "dotenv";
dotenv.config();
async function userRequestsSubmit() {
const endpoint = process.env["ENDPOINT"];
const tenantId = process.env["AZURE_TENANT_ID"];
const clientId = process.env["AZURE_CLIENT_ID"];
const username = process.env["USERNAME"];
const password = process.env["PASSWORD"];
const credential = new UsernamePasswordCredential(tenantId , clientId, username, password);
const client = createPurviewWorkflowClient(endpoint, credential);
const options: SubmitUserRequestsParameters = {
body: {
comment: "Thanks!",
operations: [
{
type: "CreateTerm",
payload: {
glossaryTerm: {
name: "term",
anchor: { glossaryGuid: "20031e20-b4df-4a66-a61d-1b0716f3fa48" },
nickName: "term",
status: "Approved"
}
}
}
]
}
};
const result = await client.path("/userrequests").post(options);
if (isUnexpected(result)) {
throw result.body.error;
}
console.log(result);
}
userRequestsSubmit().catch(console.error);
Approve workflow task
// This taskId represents an existing workflow task. The id can be obtained by calling GET /workflowtasks API.
import createPurviewWorkflowClient, {
SubmitUserRequestsParameters
} from "@azure-rest/purview-workflow";
import { UsernamePasswordCredential } from "@azure/identity";
import * as dotenv from "dotenv";
dotenv.config();
async function approvalTaskApprove() {
const endpoint = process.env["ENDPOINT"];
const tenantId = process.env["AZURE_TENANT_ID"];
const clientId = process.env["AZURE_CLIENT_ID"];
const username = process.env["USERNAME"];
const password = process.env["PASSWORD"];
const credential = new UsernamePasswordCredential(tenantId, clientId, username, password);
const client = createPurviewWorkflowClient(endpoint, credential);
const taskId = "98d98e2c-23fa-4157-a3f8-ff8ce5cc095c";
const options: ApproveApprovalTaskParameters = {
body: { comment: "Thanks for raising this!" }
};
const result = await client
.path("/workflowtasks/{taskId}/approve-approval", taskId)
.post(options);
if (isUnexpected(result)) {
throw result.body.error;
}
console.log(result);
}
approvalTaskApprove().catch(console.error);
Troubleshooting
Logging
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
:
const { setLogLevel } = require("@azure/logger");
setLogLevel("info");
For more detailed instructions on how to enable logs, you can look at the @azure/logger package docs.