0

af_fdp_to purview upload

Troubleshoot activity failures

I { "errorCode": "3608", "message": "Call to provided Azure function 'af_fdp_to_purview_upload' failed with status-'Forbidden' while invoking 'POST' on https://func-aue-dev-fdp-etl-001.azurewebsites.net' and message 'Failed to push data: 403 {"error":{"code":"Unauthorized","message":"Not authorized to access account"}}'.", "failureType": "UserError", "target": "af_fdp to purview upload", "details": []}

This is the full error I am getting, and here is my code

# main function
def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info("Starting Purview Push Job.")

    try:
        logger.info("Azure Function '__AZURE_FUNCTION__' triggered with request {req}.")

        # Parse request body

        req_body = req.get_json()
        logger.info("Azure Function '__AZURE_FUNCTION__' request body {req_body}.")

        v_tenant_id = req_body.get_mandatory("p_tenant_id")
        v_client_id = req_body.get_mandatory("p_client_id")
        v_client_secret = req_body.get_mandatory("p_client_secret")
        v_api_url = req_body.get_mandatory("p_api_url")
        v_source_path = req_body.get_mandatory("p_source_path")
        v_file_type = req_body.get_mandatory("p_file_type")
        v_description = req_body.get_mandatory("p_description")

        logger.info(f"Tenant ID: {v_tenant_id}")
        logger.info(f"Client ID: {v_client_id}")
        logger.info(f"API URL: {v_api_url}")
        logger.info(f"Source Path: {v_source_path}")
        logger.info(f"File Type: {v_file_type}")
        logger.info(f"Description: {v_description}")

        # Step 1: Authenticate

        logger.info("Started Authentication...")

        credential = ClientSecretCredential(v_tenant_id, v_client_id, v_client_secret)
        logger.info("Successfully Authenticated...")
        logger.info("Started Token Generation...")
        token = credential.get_token("https://purview.azure.net/.default").token
        logger.info("Token Generated...")

        # Step 2: Prepare data (example payload from your ADLS CSV metadata)

        payload = {
            "sourceType": "ADLS",
            "filePath": v_source_path,
            "description": v_description,
            "fileType": v_file_type
        }

        logger.info(f"Payload: {payload}")

        headers = {
            "Authorization": f"Bearer {token}",
            "Content-Type": "application/json"
        }

        logger.info(f"Headers: {headers}")

        # Step 4: Push data to Purview

        logger.info(f"Started pushing data into purview... URL [{v_api_url}] headers [{headers}] and payload [{payload}]")

        response = requests.post(v_api_url, headers=headers, json=payload)

        logger.info(f"Purview response: {response}")

        if response.status_code in [200, 202]:
            return func.HttpResponse("Successfully pushed data to Purview", status_code=200)
        else:
            return func.HttpResponse(f"Failed to push data: {response.status_code} - {response.text}", status_code=response.status_code)

    except Exception as e:
        logger.error(f"Error in Purview Push Function: {str(e)}")
        return func.HttpResponse(f"Error: {str(e)}", status_code=500)

I tried passing correct credentials through JSON body but still same issue

3
  • code is not complete. And you could remove most of the empty lines to make it shorter Commented Oct 13 at 11:51
  • I have now added the complete code. Commented Oct 14 at 3:44
  • Can you also provide output of executed script (just redact sensitive information), this would be easier to see where the issue occurs? Commented Oct 16 at 10:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.