{"id":6245,"date":"2022-10-14T08:29:26","date_gmt":"2022-10-14T08:29:26","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=6245"},"modified":"2022-10-14T09:49:58","modified_gmt":"2022-10-14T09:49:58","slug":"azure-analytics-workspace-purge","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/azure-analytics-workspace-purge","title":{"rendered":"Azure Analytics Workspace Purge"},"content":{"rendered":"<p><strong>Drop the Retention Period Down under 30 days<\/strong><\/p><p>az monitor log-analytics workspace table update &#8211;subscription %SubscriptionID% &#8211;resource-group %resourcegroup% &#8211;workspace-name %workspacename% &#8211;name AzureDiagnostics &#8211;retention-time 4 &#8211;total-retention-time 4<\/p><ol><li>Try via here <a href=\"https:\/\/learn.microsoft.com\/en-us\/rest\/api\/loganalytics\/workspace-purge\/purge?tabs=HTTP&amp;tryIt=true&amp;source=docs#code-try-0\">https:\/\/learn.microsoft.com\/en-us\/rest\/api\/loganalytics\/workspace-purge\/purge?tabs=HTTP&amp;tryIt=true&amp;source=docs#code-try-0<\/a><br \/><br \/>Give yourself the <strong>Data Purger Role for the workspace<\/strong><\/li><\/ol><p>Enter <strong>resourceGroupName<\/strong> \\ Choose Correct <strong>Subscription ID<\/strong> \\ <strong>workspaceName<\/strong><\/p><div class=\"column is-5 param-value field-body margin-top-none align-self-center\"><div>Enter the below in Body<\/div><\/div><p><span class=\"hljs-attribute\">&#8220;table&#8221;: &#8220;AzureDiagnostics&#8221;,<br \/>&#8220;filters&#8221;: [<br \/>{<br \/>&#8220;column&#8221;: &#8220;TimeGenerated&#8221;,<br \/>&#8220;operator&#8221;: &#8220;&gt;&#8221;,<br \/>&#8220;value&#8221;: &#8220;2019-01-29T19:00:00.000&#8221;<br \/>}<br \/>]<\/span><\/p><p>Click Run\u00a0<\/p><p>2. Powershell<br \/>Install-Module -Name Az.Accounts<\/p><p>[pastacode lang=&#8221;powershell&#8221; manual=&#8221;Connect-AzAccount%0A%0A%24subscriptionId%20%3D%20%22xxxxxxxxxxx%22%0A%23resourcegroup%0A%24rg%20%3D%20%22defaultresourcegroup-eau%22%0A%23workspace%0A%24ws%20%3D%20%22DefaultWorkspace-8402228f-822d-47aa-8552-4133449afe5d-EAU%22%0A%0A%24token%20%3D%20Get-AzAccessToken%20-TenantId%20%24tenantId%20-ErrorAction%20Stop%0A%0A%23POST%20https%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F%24subscriptionId%2FresourceGroups%2F%24rg%2Fproviders%2FMicrosoft.OperationalInsights%2Fworkspaces%2F%24ws%2Fpurge%3Fapi-version%3D2020-08-01%20&#8217;Content-%0A%24URI%20%3D%20%22https%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F%24%7BsubscriptionId%7D%2FresourceGroups%2F%24%7Brg%7D%2Fproviders%2F%20Microsoft.OperationalInsights%2Fworkspaces%2F%24%7Bws%7D%2Fpurge%3Fapi-version%3D2015-03-20%22%0A%0A%23%20Build%20the%20authorization%20header%20JSON%20object%0A%24authHeader%20%3D%20%40%7B%0A&#8217;Content-Type&#8217;%3D&#8217;application%2Fjson&#8217;%0A&#8217;Authorization&#8217;%3D&#8217;Bearer%20%24(%24token.token)&#8217;%0A%7D%0A%0A%0A%24body%20%3D%20%40%22%0A%7B%0A%22table%22%3A%20%22AzureDiagnostics%22%2C%0A%22filters%22%3A%20%5B%0A%7B%0A%22column%22%3A%20%22TimeGenerated%22%2C%0A%22operator%22%3A%20%22%3E%22%2C%0A%22value%22%3A%20%222019-01-29T19%3A00%3A00.000%22%0A%7D%0A%5D%0A%7D%0A%22%40%0A%0A%0A%0A%0A%0A%23%20Invoke%20the%20REST%20API%20to%20purge%20the%20data%0A%24purgeID%3DInvoke-RestMethod%20-Uri%20%24URI%20-Method%20POST%20-Headers%20%24authHeader%20-Body%20%24body%0A%23%20Write%20the%20purge%20ID%0AWrite-Host%20%24purgeID.operationId%20-ForegroundColor%20Green%0A%23%23%23%23%20END%20PURGE%20DATA%20%23%23%23%23&#8243; message=&#8221;&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]<\/p>","protected":false},"excerpt":{"rendered":"<p>Drop the Retention Period Down under 30 daysaz monitor log-analytics workspace table update &#8211;subscription %SubscriptionID% &#8211;resource-group %resourcegroup% &#8211;workspace-name %workspacename% &#8211;name AzureDiagnostics &#8211;retention-time 4 &#8211;total-retention-time 4Try via here [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4030,1464],"class_list":["post-6245","post","type-post","status-publish","format-standard","hentry","category-research","tag-analytics-workspace-purge","tag-azure"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/6245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=6245"}],"version-history":[{"count":4,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/6245\/revisions"}],"predecessor-version":[{"id":6251,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/6245\/revisions\/6251"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=6245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=6245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=6245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}