question

VasudevReddyGanganna-9013 avatar image
0 Votes"
VasudevReddyGanganna-9013 asked shivapatpi-MSFT commented

Azure File share

Hi All, I have created a Azure File share under storage account and i am looking a small custom script to generate an alert to application team if a file sits more than 5 mins in Azure file share . i could not find predefined option to do this kind of alert in Azure. So Seeking help if any one already have this type of requirement and done the alerts?

azure-files
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @VasudevReddyGanganna-9013 ,
Trying to understand your requirements better.
So you are looking for an alert like: When a new file gets created in AzureFileShare , after 5 mins you want an email alert to the application team regarding that file ?

Regards,
Shiva.

0 Votes 0 ·

Hi Shiva,
my requirements here source applications created a file in File share and some other(destination) application process should consume the file but some time Destination application could not with in the time frame.. So Source team is asking an alert ,after source team send a file to file share and if the same file sits in file share and not consumed by any other process then source team should get an alert.

in simple word saying need an alert if file actual creation time is greater than 5 mins the trigger alert

0 Votes 0 ·
Sumarigo-MSFT avatar image Sumarigo-MSFT VasudevReddyGanganna-9013 ·

@VasudevReddyGanganna-9013 If the number of items (files and folders) in the share is small, you might be able to iterate through it with a script and compare timestamps. Putting a PowerShell script into an Azure Function and then run it on a 5-Minute schedule, might work I haven't tried yet.

Not precisely an alert but once you have a script output, you can wire it into whatever automation for your needs. There is nothing built-in that helps you with this for now.
Also: if the other process just reads it (doesn't change or doesn't delete the file) then this might be bit hard to do.

Additional information: You can create an automation job using powershell script in azure automation to query the share every minute and send an alert if create time of any file is over 5 minutes old even you can try this option, You need to write a script based on your requirement

Looking forward for your reply!


Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

0 Votes 0 ·

1 Answer

shivapatpi-MSFT avatar image
0 Votes"
shivapatpi-MSFT answered shivapatpi-MSFT commented

Hello @VasudevReddyGanganna-9013 ,
As said by Sumanth you can do that using the powershell.
I was just trying to simulate your requirements using C#.net , below are the sample code snippet . Let us know if that helps.
Reference document from which below code snippet is customized , it is a console based dotnet application:
https://docs.microsoft.com/en-us/azure/storage/files/storage-dotnet-how-to-use-files?tabs=dotnet
125201-dotnetcode.txt

Try to run the above code snippet in a loop sleeping for a particular time period
Try to extend the code , get the timestamp and write the additional logic based upon your requirements after retrieving the timestamp

When you run that code the output looks something like below:

125139-image.png


Let us know if you need additional help.

Regards,
Shiva.



dotnetcode.txt (1.2 KiB)
image.png (42.4 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Shiva,

thanks for your reply. I am new to dotnet but i am trying to do the steps in visual studio code with Csharp but i am getting an error during setup and unable to proceed.

If you have any powershell script would be more helpfull to me to proceed quickly.

Installing C# dependencies...
Platform: win32, x86_64

Downloading package 'OmniSharp for Windows (.NET 4.6 / x64)' (38449 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package 'OmniSharp for Windows (.NET 4.6 / x64)'

Downloading package '.NET Core Debugger (Windows / x64)' (45337 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package '.NET Core Debugger (Windows / x64)'

Downloading package 'Razor Language Server (Windows / x64)' (62313 KB).................... Done!
Installing package 'Razor Language Server (Windows / x64)'

Finished

Failed to spawn 'dotnet --info' 126071-dotneterror.jpg


0 Votes 0 ·
dotneterror.jpg (80.0 KiB)
shivapatpi-MSFT avatar image shivapatpi-MSFT VasudevReddyGanganna-9013 ·

Hello @VasudevReddyGanganna-9013 ,
I was going through another post where you were able to extract the part of the powershell code from below post
https://docs.microsoft.com/en-us/answers/questions/482814/deleting-files-in-azure-file-share-older-than-x-da.html?childToView=526058#comment-526058

In that post you said , your code is going in a infinite loop.
Can you kindly post your customized code in detail so that I can go through and find out why it is going in a loop.

Let me know.

Regards,
Shiva.

0 Votes 0 ·