Azure Storage account having container consisting of hierarchy folders :- Create automated email if file is not uploaded to selected folders - azure

Pretty new to Azure world ,however I have tried to googling this but haven't found a good way to go about this . Let me describe the problem
I have a storage account in Azure . In the container we are storing various data files . The files are stored in tree hierarchy of folders ( Parent-> year -> month -> day).Each day new files get uploaded to the specific day folder . If the file for that specific day is not uploaded I would like to drop email notification
Please let me know if you guys have an idea of how I can get this done
I have managed to do this
Basically use logic_app to monitor the storage account when blob is added to the storage account trigger an email
Is there are better way to do this ? I would like the logic to be if for specific folders in the container if there is no file by lets say 7pm everyday then drop email

Try this:
This is some explanation of this simple logic :
You can create a schedule to trigger this logic every day at 7 PM.
Use List Blob to check if there is any file in the folder let's
say /2021/03/17 so I use the expression to combine a path for
every day checking: concat('/',utcNow('yyyy/MM/dd'))
In Azure storage, if there is no file uploaded to some path, this path not exists, List Blob will fail.
Send an email to someone if List Blob fails, set run after here so
that this action will run only after List Blob fails:
I have tested on my side and everything works as excepted :

Related

How to create a simple dashboard from Azure Storage and Fileshare

I have an azure storage account.
Inside the container, with a client-specific folder structure, every morning, some files get pushed.
I have a function app which processes and converts these files and calls some external service to work upon on these processed files.
I have got a file-share as well, which is basically mounted on a vm.
The external service, after processing the files (#3), generates the resultant success/failure files inside this file-share(#4).
Now the ask is:
Create a simple dashboard which will monitor the storage account(and in effect the container and the file-shares),it should capture & show basic information's, and should look like below table structure(with 3 simple variations of data):
FileName|ReceivedDateTime|NumberOfRecords
Original_file.csv20221011 5:21 AM|10
Original_file_Success.csv20221011 5:31 AM|9
Original_file_Failure.csv20221011 5:32 AM|1
In here the first record is captured from the Container and the second and third - both are generated in the file-share.
Also, whenever a new failure file is generated, i.e., Original file_Failure, it should send email with a predefines template adding the file name to a predefined recipient list.
Any guidance on the azure service to use?
I have seen Azure Monitor,workbook and other stuffs, but I feel that would be an overkill for such simple requirement.
Thanks in advance.

How to Trigger an email in the Event that a Logic App Trigger is skipped?

I have the below scenario:
I have a Logic App, which gets triggered once in every day(24hours).
It basically looks at a SFTP location, if there is file dropped in there, pulls it and pushes it into a BLOB storage and then deletes it from the source(SFTP).
I need to trigger an email in the events of:
If the Trigger is "Skipped", i.e. it ran but could not find any file in the SFTP.
If it failed to Upload to the BLOB Storage.
Is it possible to enable Email Trigger in the above scenarios?(1&2)
Any guidance will be appreciated as I am new in the IAC space.
Thanks in advance.
Firstly, you can List the files in FTP and pass the name to get the content of the files using List files in folder and Get file content actions of SFTP connector.
If the Trigger is "Skipped", i.e. it ran but could not find any file in the SFTP.
For this, in the next step you can use a condition action to check if the file has been uploaded for that day by comparing the last modified time with the current date. If yes, then create a file in the blob storage with the file contents from Get file content step. Below is the flow of my logic app.
If it failed to Upload to the BLOB Storage.
For this you can create another condition action and check if the file is been created or not by using actions('Create_blob_(V2)')['outputs']['statusCode']. Below is the complete code of my Logic app

Azure datafactory triggers for any blob files get appened

I am trying to copy the databricks logs from one folder to another, Since I am sending databricks logs to storage account which is append blob. My objective as any new blob/any files get appended I need to run the copy activity.
I tired storage events trigger but it is not running if any logs get appended to the same files. Is there any way to run the pipeline immediately if any files appended or new folder dd/mm/yyy format get created.
Thanks
Anuj gupta
There is no out-of-the-box method to trigger when a blob is appended, there is a similar ask here, you can log a more precise one to get an official response.
Or you can use Create a custom event trigger to run a pipeline in Azure Data Factory with Azure Blob Storage as an Event Grid source where event Microsoft.Storage.BlobCreated is "triggered when a blob is created or replaced." (Append Block succeeds only if the blob already exists.)
Also, perhaps with Microsoft.Storage.BlobRenamed, Microsoft.Storage.DirectoryCreated & Microsoft.Storage.DirectoryRenamed

Load the latest folder from azure blob storage to azure data factory

I have a scenario where I have to fetch the latest folder from the blob storage container and then process all files under that folder through Azure data factory, currently, all folder name based on timestamp and as we know CloudBlobDirectory don't hold LastModified Date so there is no way to extract metadata from Azure data factory activity like last modified time so that I can iterate with the timestamp and process the content.
Is there any other way to perform something like sort on the folder name and then pick it based on string sort (on folder name )?
I tried something similar using Azure functions.
Please have a look and tell if its of use.
https://www.youtube.com/watch?v=eUMjghIEsjw

Creating a folder using Azure Storage Rest API without creating a default blob file

I want to create following folder structure on Azure:
mycontainer
-images
--2007
---img001.jpg
---img002.jpg
Now, one way is to use PUT Blob request and upload img001.jpg specifying the whole path as
PUT "mycontainer/images/2007/img001.jpg"
But, I want to first create the folders images and 2007 and then in a different request upload the blob img001.jpg.
Right now when I tried to doing this using PUT BLOB request:
StringToSign:
PUT
x-ms-blob-type:BlockBlob
x-ms-date:Tue, 07 Feb 2017 23:35:12 GMT
x-ms-version:2016-05-31
/account/mycontainer/images/
HTTP URL
sun.net.www.protocol.http.HttpURLConnection:http://account.blob.core.windows.net/mycontainer/images/
It is creating a folder but its not empty. By, default its creating an
empty blob file without name.
Now, a lot of people say we can't create a empty folder. But, then how come, we can make it using the azure portal as the browser must be sending some type of rest request to create the folder.
I think it has to do something with Content-Type i.e. x-ms-blob-content-type, which should be specified in order to tell azure that its a folder not a blob.
But, I am confused.
I want to first create the folders images and 2007 and then in a different request upload the blob img001.jpg
I agree with Brendan Green, currently, Azure blob storage just enable us to create virtual directory structure by naming blobs with path information in their names.
I think it has to do something with Content-Type i.e. x-ms-blob-content-type, which should be specified in order to tell azure that its a folder not a blob. But, I am confused.
You could check the description of Request Headers that could be set for Put Blob operation and you will find it does not support creating an empty folder by specifying some request headers.
Besides, as Gaurav Mantri said, if you really want to create an empty folder structure without content, you could try to use Azure File storage and it also enables us to use REST API to access Azure File storage. And the Create Directory operation cloud be used to create a new directory under the specified share or parent directory.
PUT https://myaccount.file.core.windows.net/myshare/myparentdirectorypath/mydirectory?restype=directory
This is not possible - the folder structure is virtual only.
See Get started with Azure Blob storage using .NET. You can only create a container, and everything else held in that container is a blob.
Excerpt:
As shown above, you can name blobs with path information in their
names. This creates a virtual directory structure that you can
organize and traverse as you would a traditional file system. Note
that the directory structure is virtual only - the only resources
available in Blob storage are containers and blobs.

Resources