Loading...

Deletion of logs from $logs container from ADLS gen2 storage account using PowerShell

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.

 

Deeksha_S_A_0-1668583848971.png

Step 2:

From the left-hand pane, select Runbooks.

 

Deeksha_S_A_1-1668583848979.png

Step 3:

On the Runbooks page, Create a runbook runbook (as shown as an example below

 

Deeksha_S_A_2-1668583848982.png

 

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

 

Deeksha_S_A_3-1668583848987.png

 

Step 5:

On the Runbooks page, select a runbook, and then click Start

Deeksha_S_A_4-1668583848989.png

Step 6:

On the Jobs pane, you can view the status of the runbook job.

Deeksha_S_A_5-1668583848992.png

Step 7:

Scheule job with Add a Scheule to make it run the Runbook automatically

Deeksha_S_A_6-1668583848997.png

 

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

Deeksha_S_A_7-1668583849005.png

 

  1. In General tab, you can set scheduler name and description about the task like for what purpose the task has created.

Deeksha_S_A_8-1668583849009.png

 

  1. Switch to the Trigger tab and click the New button. Here, you can set conditions that trigger a task.

Deeksha_S_A_9-1668583849014.png

 

  1. Then open the next tab ‘Actions’ and click the ‘New’ button.

Deeksha_S_A_10-1668583849017.png

 

  1. 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.

Deeksha_S_A_11-1668583849023.png

 

  1. On the Settings tab, you can set additional advanced settings to control the task execution.

 

Deeksha_S_A_12-1668583849028.png

 

  1. Finally, click Ok to create a scheduled script.

Published on:

Learn more
Azure PaaS Blog articles
Azure PaaS Blog articles

Azure PaaS Blog articles

Share post:

Related 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...

1 year ago

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...

1 year ago

[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...

1 year ago

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 ...

1 year ago

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 ...

1 year ago

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...

1 year ago

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...

1 year ago

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...

1 year ago

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...

2 years ago

[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...

2 years ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.