Unzip and Rename underlying File using Azure Logic App - azure

Possible to rename an underlying file while Unzipping using Logic App? I am calling an HTTP activity to download a ZIP file. That Zip contains only 1 Underlying file with some value appended to the name. I want to store the Unzipped file with a better name so that it can be used further. Is it possible ?
Incoming ZIP File --> SAMPLEFile.ZIP
Underlying File --> SampleTextFile20200824121212.TXT
Desired File --> SampleTextFile.TXT
Suggestions ?

As far as I know, we can't implement this requirement directly in "Extract archive to folder" action. We can just rename the file by copy it from one folder to another folder (shown as below).
You can create a new ticket on feedback page to ask azure team for this feature.

Related

How to trigger Azure Logic App when dropping file in Sharepoint folder

I created a Logic App that uses the Sharepoint trigger "When a file is created or modified in a folder". It works perfectly when I upload a file in Sharepoint online (in a Sharepoint browser tab). But, it doesn't work when I drop a file in my synced Windows explorer folder.
I read that someone faced the same problem: https://learn.microsoft.com/en-us/answers/questions/41215/logic-app-why-does-sharepoint-file-properties-trig.html. Here it says:
Move files and flow runs When you move one or more files from one
document library to another, the original file is moved from the
source library to the destination library. Moving the file does not
alter any custom metadata, including when the file was created and
modified. Hence, this action does not trigger any flows for those file
updates associated in the library where it was moved.
Syncing files to your OneDrive for business and SharePoint document
libraries When users sync one or more files from one document library
to another, the original file is moved (synced) from your client to
the destination library. Syncing the file will not alter any custom
metadata including when the file was created and modified. Hence, this
action will not trigger any flows for those file syncs in that library
or in your OneDrive for business.
The thing is that I NEED this Logic App to run by just dropping this file in a Windows Explorer folder (which is a Sharepoint folder shared with a certain person). Do you know how can I achieve this?
It started working for me when I used the OneDrive - When a file is created Connector because we use OneDrive for Windows Explorer and need to include the folder where the trigger should be invoked. We must set Include subfolder to true if we want the trigger to be fired while adding any file to the subfolders.
Here are the screenshots of the logic app working
When adding file in subfolders
When adding file in root folder

What is the best way to extract .zip file/folder structure then commit to Github using Github API?

I'm trying to place some config files under version control using Github. The ONLY way to get these particular config files is via a GET request to the hosting server. Server responds with a .zip file.
.zip file structure looks similar to:
|-Folder1
--|-File1.json
--|-File2.json
--|-Pic1.jpg
|-Folder2
--|-File3.json
--|Folder3
----|Pic2.jpg
|-File4.json
|-File5.json
As you can see, its a mix of text and binary files. Also has a nested folder structure.
I need to:
Commit this .zip file to Github using the Github REST API (no problem there)
But BEFORE committing, how can I programmatically extract the folders and files (LEAVING THE FOLDER STRUCTURE IN PLACE)
Commit the results to Github
I've checked the question/solutions mentioned here, but they don't quite match/are a few years old.
Anyone have a workflow for doing this? I have to imagine SOMEONE has come across similar requirements.
I ended up using Power Automate to handle this.
Basically,
GET .zip file
Add it to OneDrive for Business
Extract it there (folder structure is "flattened", but luckily OneDrive "keeps" it by renaming each file)
Example: Folder1/File1.json in the .zip becomes Folder1_File1.json once extracted
When committing to Github via api, I just did a replace for the filename; INCLUDING the / as part of the path.
Example URL: https://api.github.com/repos/SeaDude/replace(items('FOR_EACH_app')?['properties']?['DisplayName'], ' ', '-')/contents/replace(items('FOR_EACH_source_file_2')?['Name'],'_','/')
Apparently, you can specify an empty (or non-empty) path as part of an API commit. If the directory is empty, Github will create it!

How to create a folder on a SFTP server in Azure Logic Apps?

I verified the user has permission, but I do not see it showing up in the list of possible Logic Apps:
Here is a screenshot of what I can do and it is missing Create Folder.
There is no create folder action available in the SFTP connector. Share your idea here
https://feedback.azure.com/forums/287593-logic-apps
You can get around this problem by using the "SFTP Extract archive to folder". You need to put a file that contains a single zipped file on your SFTP server. Then use the connector just mentioned to unzip the zip file to the new folder you want to create. It will then create the required folder.
So I have a zip file called CreateFolder.zip which I unzip to a new folder. The SFTP server must have unzip installed, it won't work work with gunzip.

Azure Logic Apps FTP file content

I'm using Azure Logic Apps to copy files from FTP to Blob Storage. I'm using the action "FTP - When a file is added or modified" and after this I copy the file content to a Blob Storage.
The problem is that the file is being copied to Blob Storage before it is completely added to the FTP, and I get partial files.
Is there any way to hold Azure Logic Apps such that it will only copy the file after it is completed?
This behavior happens when your FTP file system does not provide file locking. Similar behavior can occur when using the FTP-adapter in BizTalk.
In BizTalk, the best way to handle this is by modifying the client that is creating the file on FTP so that it uses temporary filenames.
Client creates file ftpFile.tmp
Client writes file content
Client renames ftpFile.tmp to ftpFile.xml or whatever extension is needed
BizTalk only picks up files with extension .xml
Major problem for me with the Logic Apps FTP connector is that you can't specify a file mask in the designer when using the connector as a trigger, which is strange, because i remember that option being available in the first version of logic apps.
You need to Enable the Include File Content Option.
You can do this in 2 ways.
1.
Go to LogicAppDesigner->Expand your FTP-Trigger ->Set yes to Include File Content
Like this
Go to Logic App Code View-> find the Trigger JSON- > Add "includeFileContent": true inside the "Queries"

How do I reference a text file from an Azure WebJob?

I'm creating a web job on Azure that is going to be a c# console application (.exe). Inside this program I need to read a text file from the file system. Is there a way to include the text file I need in the executable? Where do I put the file and how do I reference it?
I also don't want anyone (via the website) be able to access the file.
Just deploy the text file alongside the executable, and you'll be able to open it in the current folder.
If deploying the WebJob from Visual Studio, make sure to mark the text file's properties as 'Copy if newer' to make sure it gets deployed.
Follow instead of putting a file location in the value as parameter
just put this as I show you here
Put it in Appconfig file for path as
to copy this text file into your bin/debug folder to
Make zip folder as usual, put that test file int "debug.zip"

Resources