Deletion of logs from $logs container from ADLS gen2 storage account using PowerShell
Background:
Many times, we have a requirement to delete the older logs from $logs as the Retention days as it was not supported for ADLS gen2 storage account.
Please note Product team already worked on this fix and in case automatic deletion is not working can follow the below steps
Please refer to article https://docs.microsoft.com/en-us/azure/storage/common/manage-storage-analytics-logs?tabs=azure-portal#modify-log-data-retention-period for more information
Deletion of logs from the $logs can be achieved from the following options
- Azure Storage explorer
- REST API
- SDK’s
- PowerShell
- Azure Data Factory
This blog demonstrates how to automate deleting logs from $logs with help PowerShell Runbook and Task Scheduler
Please refer to below Powershell script which helps to delete blobs from $logs container (Please note customization and optimization should be needed for the script based on requirement)
CodeRepository/DeleteBlobsFrom$logs.ps1 at master · Azure-Developer-Support/CodeRepository · GitHub
PowerShell runbook
Step 1:
In the Azure portal, select Automation and then Create an Automation account.
Step 2:
From the left-hand pane, select Runbooks.
Step 3:
On the Runbooks page, Create a runbook runbook (as shown as an example below
Step 4 :
Once the Runbook gets created successfully, add the Deletion Powershell script in the Edit Powershell Runbook editor->click on Save and then click on Publish
Step 5:
On the Runbooks page, select a runbook, and then click Start
Step 6:
On the Jobs pane, you can view the status of the runbook job.
Step 7:
Scheule job with Add a Scheule to make it run the Runbook automatically
Step 8:
Click on Schedule(Link a Schedule to your runbook) ->+Add a schedule ->Enter name, Description,job starts time, Timezone, Recurrence(Once or Recurring)-> Create
Task Scheduler:
Open Task Scheduler (it can be found in the ‘Administrative tools’ or by pressing ‘Windows+R’ to open run and then type “taskschd.msc”.)
To run a script from Task Scheduler, follow these steps.
1. Open Task scheduler –> Task Scheduler Library –> Create Task
- In General tab, you can set scheduler name and description about the task like for what purpose the task has created.
- Switch to the Trigger tab and click the New button. Here, you can set conditions that trigger a task.
- Then open the next tab ‘Actions’ and click the ‘New’ button.
- Once configured, you can specify conditions to determine whether the task should run. The task will not run if any condition specified here is not true.
- On the Settings tab, you can set additional advanced settings to control the task execution.
- Finally, click Ok to create a scheduled script.
Published on:
Learn moreRelated posts
Azure Storage - TLS 1.0 and 1.1 retirement
Overview TLS 1.0 and 1.1 retirement on Azure Storage was previously announced for Nov 1st, 2024, and it was postponed recently to 1 year later...
Efficient Management of Append and Page Blobs Using Azure Storage Actions
Overview In Azure Storage, Blob Lifecycle Management (BLM) allows you to automate the management of your data based on rules defined by...
[Azure AI Search] Internal Server Error when creating CMK encrypted objects
Scenario Customers follow the Microsoft doc to create CMK encrypted objects (data source, index etc.), but get the 500 Internal Serv...
Optimizing Azure Table Storage: Automated Data Cleanup using a PowerShell script with Azure Automate
Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...
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 ...
Restoring Soft-Deleted Blobs with multithreading in Azure Storage Using C#
Blob soft delete is an essential feature that safeguards your data against accidental deletions or overwrites. By retaining deleted data for a...
Performing simple Azure Table Storage REST API operations using curl command.
The blog provides guidance to perform simple Table Storage REST API operations such as Create table, Delete Table, Insert entity, Delete entit...
Bulk delete all the old jobs from the batch account
Deleting a Job also deletes all Tasks that are part of that Job, and all Job statistics. This also overrides the retention period for Task dat...
Utilizing Azure Storage and Runbooks for scheduled automated backups of Azure SQL Databases
In this article, we are going to provide detailed steps to create a scheduled Azure SQL Database backup to storage account using automation. T...
[Azure Service Bus] JMS messages getting dead-lettered
The article discusses a problem where numerous messages end up in the dead letter queue (DLQ) when the JMS service bus consumer connects to th...