Wednesday 9 February 2022

Azure File Share Usage Report for all Subscription in your Tenant (Email and Web hooks notification)

 I was setting up monitoring for my Azure environment and I had an requirement to email the Fileshare usage of all fileshares in a tenant to Support team on daily Basis and also sent notification in Slack. I used PowerShell to consolidate the data and Logic apps for the integration for Slack notification.

To breakdown the script for better understanding, I have used a credential from credential manager which had RBAC permissions to all subscriptions in the tenant and I used the function in  https://gallery.technet.microsoft.com/scriptcenter/Accessing-Windows-7210ae91 for my Azure and SFTP authentication using the credentials already in credential manager. I am using Azure Management API's to get the information of the File storage as I found PowerShell Modules had restriction to Storage account opened only for particular subnet outside of the server I am running the script. I have used the method in  https://www.powershellgallery.com/packages/LSECosmos/0.2.1-alpha/Content/Get-AzAccessToken.ps1 for API Authentication.


The script will consolidate result in HTML format and Json format. Json format will be sent as Payload to Webhooks to Logic Apps were you can integrate with Slack or Teams alerts. HTML format will be styled with yellow rows for 80 to 90% and Red Rows for usage above 90% as below.

File Share Usage

StorageAccountName

SubscriptionName

ResourceGroupName

ShareName

TotalCapacity(GB)

UsedSpace(GB)

PercentageUsed

StgAcctName1

Sub-1

RG-1

FileShare-1

1

0

0

StgAcctName2

Sub-1

RG-2

FileShare-2

10

0

2

StgAcctName3

Sub-2

RG-3

FileShare-3

100

0

0

StgAcctName4

Sub-3

RG-4

FileShare-4

1024

926

90

StgAcctName5

Sub-4

RG-5

FileShare-5

250

91

37

StgAcctName6

Sub-4

RG-5

FileShare-6

1024

845

83

 

Copyright © 2022 Vinoth N Manoharan.The information provided in this post is provided "as is" with no implied warranties or guarantees.

3 comments: