Optimizing Azure Table Storage: Automated Data Clean-up using a PowerShell script with Azure Automat
Scenario
This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from various applications or any unused older data. Over time, this data grows significantly, making it necessary to periodically clean up old entries to maintain performance and manage costs. You decide to automate this process using Azure Automation. However, lifecycle management policies are limited to the Blob service only.
By scheduling a PowerShell script, you can efficiently delete outdated data from your Azure Table Storage without manual intervention. This approach ensures that your storage remains optimized, and your applications continue to run smoothly.
Below is the PowerShell script which delete Table Entities based on Timestamp: -
Connect-AzAccount -Identity $SubscriptionID = "xxxxxxxxxxxxxxxxxx" $StorageAccount = "xxxxxxxxxxxxxxxxxxx" foreach ($table in $alltablename) {
#DISCLAIMER |
Here are the steps to schedule a PowerShell script in Azure Automation :-
-
Create an Azure Automation Account by following the link:
-
Add Modules to Azure Automation Account:
- Navigate to the created automation account page.
- Go to the "Modules" tab under the "Shared Resources" section and choose the "Add a module" option.
- You can either manually import modules from your local machine or import inbuilt modules from the gallery.
- In this article, we will proceed with the gallery option.
- Search for the Storage Modules.
- Add the module with recommended Runtime version.
-
Create a PowerShell Runbook:
- In the Azure Portal, navigate to your Automation Account.
- Under "Process Automation", select "Runbooks".
- Click on "Create a runbook".
- Enter a name for the runbook, select "PowerShell" as the Runbook type, and click "Create".
- Once Runbook is created, in the "Edit PowerShell Runbook" page.
- Enter your PowerShell script and click "Publish".
-
Schedule the Runbook:
- Go to the respective Runbook and choose the "Link to schedule" option.
- Select the "Link a schedule to your Runbook" option and choose the appropriate schedule.
- If you go ahead wit Schedule option, you can create a new schedule by specifying the name, description, start date, time, time zone, and repeating information.
-
Monitor the Runbook:
- You can monitor the runbook's execution by going to the Jobs section under Process Automation in your Automation account.
- Here, you can see the status of the runbook jobs, view job details, and troubleshoot any issues.
These steps should help you schedule your PowerShell script in Azure Automation. If you have any more questions or need further assistance, feel free to ask!
References :-
Published on:
Learn moreRelated posts
Primer: Output Data Generated with an Azure Automation Runbook to a SharePoint List
The second part of the Azure Automation runbook primer brings us to output, specifically how to create items generated by a runbook in a Share...
Databricks vs Azure Synapse Analytics: A Comprehensive Comparison for Modern Data Solutions
Table of Contents Introduction Data is at the core of modern business decision-making. As companies increasingly rely on data-driven insights,...
Primer: How to Use Azure Automation to Run Microsoft Graph PowerShell SDK Scripts
A reader asked why it seems so difficult to use Azure Automation runbooks to process Microsoft 365 data. In fact, it's not so hard, and here's...
Extending Regular Expressions (Regex) Support on Azure SQL Managed Instance (MI)
We are happy to announce the Private Preview of Regular Expressions (Regex) support on Azure SQL Managed Instance (MI). This new feature bring...
Shield your Copilot with Azure AI
Azure Confidential Clean Rooms demonstration
Final Days for the MSOnline and AzureAD PowerShell Modules
After many twists and turns since August 2021, the MSOnline module retirement will happen in April 2025. The AzureAD module will then retire i...
Join the Conversation: Call for Proposals for Azure Cosmos DB Conf 2025!
Are you passionate about Azure Cosmos DB? Do you have insights, experiences, or innovations that the developer community would love to hear? N...