Summary
In today's blog, I want to discuss the SharePoint storage quota metric and its significance for business owners. While this metric is easily accessible in the browser, it can be challenging to pull programmatically. Additionally, there is no built-in warning mechanism for when you are about to run out of storage. To address this problem, I have found a solution using Logic Apps. In this blog, I will walk you through the process of retrieving the storage quota metric and demonstrate how to make it more user-friendly. Let's dive in!
The Challenge of Accessing SharePoint Storage Quota Metric Programmatically
Before we delve into the solution, let's understand the challenge at hand. While the SharePoint storage quota metric is readily available in the browser, accessing it programmatically can be tricky. The Microsoft Graph does not provide direct access to this data, and using the old SharePoint PowerShell module requires bypassing security measures.
To overcome these limitations, I have discovered a workaround using Logic Apps, which allows us to retrieve the storage quota metric without compromising security.
Using Logic Apps to Retrieve the SharePoint Storage Quota Metric
Logic Apps provide a powerful solution for programmatically accessing the SharePoint storage quota metric. Let's walk through the steps involved:
Create a recurrence trigger: Begin by setting up a trigger for your Logic App. For this demonstration, let's assume we want to send an email based on the storage quota information. You can choose any trigger that suits your needs.
Make an HTTP call to SharePoint: The next step is to make an HTTPS call to your SharePoint admin site. This call will retrieve the storage quota metric. Specify the SharePoint API endpoint, including the required headers such as "accept" and "content type". These values can be obtained from the SharePoint API documentation.
Retrieve the storage quota metric: Once the HTTPS call is made, you will receive a response containing the storage quota metric. Extract the required information, such as the available storage in MB, from the response. This metric will serve as a key indicator of your remaining storage.
Making the Storage Quota Metric More User-Friendly
While the raw storage quota metric is valuable, it can be more user-friendly with a few additional steps. Here's how:
Pass the response body to a Parse JSON function: Use the Parse JSON function in Logic Apps to generate a schema for the response body. This step ensures that the data is properly formatted for further processing.
Initialise a variable for the available storage in GB: To make the metric easier to work with, initialise a variable specifically for the available storage in gigabytes. This variable will store the converted value later on.
Perform a division to convert the available storage: Use the Div function to divide the available storage in MB by 1024. This conversion will give you the available storage in GB, which is a more commonly used unit.
With these additional steps, the storage quota metric becomes more user-friendly and easier to interpret.
Utilising the Storage Quota Metric for Business Purposes
Now that you have access to the storage quota metric in a convenient format, you can leverage it for various business purposes. One such application is setting up notifications when the available storage reaches a critical level. Here's an example:
Add a condition: In your Logic App, add a condition to check if the available storage is less than or equal to a specific threshold value. For instance, you can set a warning when the available storage is 100 GB or lower.
Trigger an action: Within the condition, you can define an action to send an email notification, either to yourself or a shared mailbox. This notification will alert you when the storage reaches a critical level, allowing you to take appropriate action.
By implementing this solution, business owners can effectively manage their SharePoint storage and avoid unexpected disruptions due to storage limitations.
In Conclusion
The SharePoint storage quota metric is a vital piece of information for business owners. By utilising Logic Apps, you can programmatically retrieve this metric and make it more user-friendly. This enables proactive management of storage and ensures business continuity. If you have any real-world scenarios or Azure-related challenges, feel free to share them in the comments. Until next time, happy SharePointing!