Read XML text from a xml file and pass it to web activity

Santhi Dhanuskodi 205 Reputation points
2024-03-05T06:05:15.8233333+00:00

Hi,

I have a xml file in storage account in a container. I want to read this xml file and get full xml text present in the file and pass it to web activity(Calling an API with body text as this XML).

I am using lookup activity to read the file, but it gives me output in json. how can i get exact xml content within the file and pass it to web activity?

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,870 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,575 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,012 questions
{count} votes

2 answers

Sort by: Most helpful
  1. KarishmaTiwari-MSFT 18,747 Reputation points Microsoft Employee
    2024-03-07T20:06:56.0866667+00:00

    @Santhi Dhanuskodi Thanks for posting your query on Microsoft Q&A.

    You mentioned that you have an XML file in blob container in Azure Storage account. To allow Azure Data Factory to have write permission to your chosen container,
    create a shared access token first:

    • Go to your Storage Account.
    • Click on “Containers” under Data Storage.
    • Select your container.
    • Click “Shared access tokens” under Settings.
    • Grant the required permissions: Read, Add, Create, and Write.
    • Set an appropriate expiry date.
    • Click “Generate SAS token and URL” and copy the Blob SAS URL at the bottom.

    User's image

    Set Up the Web Activity:

    • Create a new Web activity (e.g., name it “Save Output to Blob”).
    • Link it to your source activity (e.g., the one reading the XML file).
    • Open the properties for the newly created Web Activity and select the Settings tab.
    • Set the URL to be your previously copied Blob SAS URL, adding the desired blob file name after the container name in the URL.

    Passing XML Content to Web Activity:

    Refer to this Stack overflow post: https://stackoverflow.com/questions/70983285/reading-and-writing-an-xml-file-using-adf-lookup-activity

    If you have any questions, let me know via comments.

    0 comments No comments

  2. Pinaki Ghatak 2,795 Reputation points Microsoft Employee
    2024-04-24T08:44:23.7833333+00:00

    Hello @Santhi Dhanuskodi

    To get the exact XML content within the file, you can use the Get Metadata activity after the Lookup activity. In the Get Metadata activity, you can specify the file path and select the Child Items option. This will give you the metadata of the file, including the size and modified date. You can then use the Copy Data activity to copy the file to a blob storage and select the Binary option for the Copy Behavior.

    This will copy the file as binary data instead of JSON. Finally, you can use the Web activity to call the API with the body text as the XML content.

    Here's an example pipeline:

    1. Lookup activity to get the file path and name.
    2. Get Metadata activity to get the metadata of the file.
    3. Copy Data activity to copy the file to a blob storage as binary data.
    4. Web activity to call the API with the body text as the XML content.

    Let us know if this works.

    0 comments No comments