Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.36k stars 2.71k forks source link

Using Azure SDK for Python to run Workflows in Azure Purview #36234

Open RicSpd opened 1 week ago

RicSpd commented 1 week ago

Describe the bug We are working inside Azure Databricks. We are trying to use Azure SDK for Python (previously we tried to use Purview REST APIs as can be seen here) to make a user request that should be able to trigger a Purview workflow run. The workflow should trigger whenever the user is trying to update an asset, for example its userDescription.

To Reproduce We tried the following code:

from azure.identity import ClientSecretCredential
from azure.purview.workflow import PurviewWorkflowClient

client_id = 'XXX'
client_secret = 'YYY'
tenant_id = 'ZZZ'
purview_endpoint = "https://ABCDE.purview.azure.com"

def get_credentials():
     credentials = ClientSecretCredential(client_id=client_id, client_secret=client_secret, tenant_id=tenant_id)
     return credentials

credentials = get_credentials()
client = PurviewWorkflowClient(endpoint=purview_endpoint, credential=credentials)

json_payload = {
    "operations": [
        {
            "type": "UpdateAsset",
            "payload": {
                "entities":
                    {
                        "typeName": "azure_sql_table",
                        "attributes": {
                            "guid": "f00553c6-7a45-479f-b2fe-f9f6f6f60000",
                            "userDescription": "New description from ADB with workflow API",
                            "qualifiedName": "mssql://ABCDE.database.windows.net/.../dbo/...",
                            "name": "RichiesteOffertaBandite",
                            "description": "Description from ADB with workflow API"
                        }
                    }
            }
        }
    ],
    "comment": "please work"
}

response = client.user_requests.submit(
        user_requests_payload = json_payload,
        content_type = 'application/json'
)

We are getting the following error:

{'error': {'requestId': '3ea14555-aa4c-48e7-b1b6-1d683f39515b',
  'code': 'Workflow.DataCatalogError.InvalidJsonRequestPayload',
  'message': "Invalid Json request payload: '.entities(missing)'"}}

We do not understand what is missing inside "entities". The documentation (link and link) is really not clear on what a user request payload should contain, and we think we have inserted the typeName and attributes correctly. Any suggestions?

github-actions[bot] commented 1 week ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @yifan-zhou922.

kristapratico commented 1 week ago

@RicSpd thanks for your feedback, we'll take a look and get back to you as soon a possible. cc @yifan-zhou922