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.
- Go to the respective Runbook and choose the "Link to schedule" option.
-
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
How to Integrate Azure Service Bus with Microsoft Dynamics 365 CRM Step by Step with Example?
Keeping data flowing between applications is critical in today’s connected business world. Organizations using Microsoft Dynamics 365 CR...
Enhancing Secure Sign-Ins with Temporary Access Pass in Azure Active Directory
Introduction While working on improving user account recovery scenarios, a common challenge often arises: how to securely allow a user to sign...
Azure SDK Release (September 2025)
Azure SDK releases every month. In this post, you'll find this month's highlights and release notes. The post Azure SDK Release (September 202...
Batch Processing Triggered Pipeline Runs in Azure Synapse
This post describes a pattern for batch processing triggered pipeline runs in Azure Synapse
Reliably refreshing a Semantic Model from Azure Data Factory or Synapse Pipelines
This post describes a pattern for reliably refreshing Power BI semantic models from Azure Data Factory or Azure Synapse Pipelines.
Power Pages Fundamentals #24: Boosting Portal Security with Azure Single Sign-On: Quick Read Series
Contoso Motors is a large automotive service company.They have built a Power Pages customer portal for their external partners and customers t...
Building Azure functions that never store secrets — ever
What if your function could hit Microsoft Graph with no client secrets, no certs, and no Key Vault entries? That is exactly what a Managed id...
Azure Functions missing after zip deploy from GitHub Actions
Learn how to troubleshoot Azure Functions that don't appear after zip deployment from GitHub Actions, including platform architecture configur...