My logicapp having step as create file .txt and then rename file .xml read and rename blank file
azure logic app using sftp ssh crete file connector write blank file and then file get rename before content added to file how to prevent this in azure logic app sftp crete file connector
Azure Logic Apps
-
Vinodh247 19,656 Reputation points
2024-09-22T11:33:24.9366667+00:00 Hi ,
Thanks for reaching out to Microsoft Q&A.
To resolve the issue where your file is getting created as '.txt' and then renamed to '.xml' before content is added in your Azure Logic App using the SFTP SSH connector, you can follow these steps to ensure that the file content is written before renaming occurs...
Check File Creation Timing: Ensure that the content is written to the file completely before the renaming step is executed. To do this, you can introduce additional logic to check for file creation completion.
Add Delay Before Renaming: Insert a delay action between the file creation and renaming steps to give enough time for the file content to be fully written before renaming. Use the 'Delay' action in Azure Logic Apps to pause for a few seconds after file creation.
Create a Temporary Filename: When using the SFTP Create File connector, write the content to a temporary file (ex., 'filename.tmp') first. Then, after verifying that the content is completely written, rename the file to the desired '.xml' extension.
- Here’s a potential sequence for the logic:
- Create Temporary File: Create the file with a '.tmp' extension.
- Write Content: Add the content to the '.tmp' file.
- Delay (optional): Introduce a small delay if needed.
- Rename File: Rename the '.tmp' file to the desired '.xml' extension.
Use Conditional Logic: You can add a condition that checks whether the file size is greater than 0 before proceeding with the rename step. This ensures that the file is not renamed while still empty.
Test with Different File Size Scenarios: Ensure that the solution works well for various file sizes and configurations, especially if large files are involved, to prevent premature renaming.
By writing to a temporary file and then renaming it only after ensuring that the content is fully written, you can avoid the issue of blank files being renamed before the content is added.
Try this and let me know...
Please 'Upvote'(Thumbs-up) and 'Accept' as an answer if the reply was helpful. This will benefit other community members who face the same issue.
-
MayankBargali-MSFT 70,401 Reputation points
2024-09-23T09:52:12.77+00:00 @Rashmiramchandra Prabhu Thanks for reaching out.
Please correct if my understanding is correct that you have below flow and you observed that the file name gets changes post the file is update? or you are getting file not found error while you try to use the same file name in the Update file action?
Create File action --> Update File action
Can you please share the screenshot of your actions/flows and what value you are passed in those action so I can review and assist you further.
-
Rashmiramchandra Prabhu 46 Reputation points
2024-09-23T09:57:03.84+00:00 Hi Mayank I dont find any issue in logic app file get created and rename also but in sftpt its a blank xml file so I suspect that Txt file get created first and before writing content into it it rename and fetched by receiving application and they compalining that they received blank file
-
MayankBargali-MSFT 70,401 Reputation points
2024-09-23T10:01:31.5533333+00:00 @Rashmiramchandra Prabhu If the file is empty then it means that the body is not passed in the binary format to the action. Can you please confirm and please share the screen shoot of your individual action what value is passed along with other action if you are using other action value in any of these two actions.
-
Rashmiramchandra Prabhu 46 Reputation points
2024-09-23T11:14:52.0033333+00:00 We are sending daily more than 20 files and one of the file is blank so its not content format .Even Create file output is showing file size as 9365 so I am not sure this blank file is due tpto logic app or its issue of receiving application as rename file output also showing same size
-
MayankBargali-MSFT 70,401 Reputation points
2024-09-26T10:24:19.52+00:00 @Rashmiramchandra Prabhu As per the above screenshot the logic app crates the files correctly if it is the same run for which you have observed the blank file at SFTP end. You may need to review the SFTP server logs to know more details how the file become empty.
In case if the above screenshot is not for the same filename for which you observe the empty file then I will suggest you to validate the run history to confirm if the same file name that was empty was created from logic app. In case if it is yes then checking the previous action in logic app to validate why the content was empty.
To troubleshoot the issue from logic app end you can always review the run history and individual action to know the input/output of individual actions.
Sign in to comment