Azure Application Insights, how to change daily cap by Azure CLI

4.9k views Asked by At

I'm trying to change daily cap for data transfer for all my Application Insights on Azure. Is there any way to change it for all of them?

I can't find how to do it by using Azure CLI.

Thank you.

3

There are 3 answers

0
RonDBA On BEST ANSWER

You can change the daily cap with the Azure PowerShell cmdlet Set-AzureRmApplicationInsightsDailyCap.

Login-AzureRmAccount
Set-AzureRmContext -SubscriptionName "Your Sub Name"

function Set-DailyCap {

    $AI = Get-AzureRmApplicationInsights | Select ResourceGroupName, Name 

    $AI | foreach { 
    write-output ("Attempting to set daily cap for App Insights in resource group {0} instance {1}" -f $_.ResourceGroupName, $_.Name)
    Set-AzureRmApplicationInsightsDailyCap -ResourceGroupName $_.ResourceGroupName -Name $_.Name -DailyCapGB 0.2 

    }
}

Set-DailyCap
3
juvchan On

There is no way you can change the daily cap of your application insights component using Azure CLI or even Azure REST APIs as of today.

To change it, use the Daily volume cap blade, linked from the Data Volume Management blade (see below). Note that some subscription types have credit which cannot be used for Application Insights. If the subscription has a spending limit, the daily cap blade will have instructions how to remove it and enable the daily cap to be raised beyond 32.3 MB/day.

enter image description here

Data source/Reference:

https://learn.microsoft.com/en-us/azure/application-insights/app-insights-pricing#data-rate

0
Don Fouts On

Here is a modified version of @RonDBA's solution, which includes some logic to parse the names and set limits based on their name. Using this script, I was able to update hundreds of daily caps in a matter of seconds.

import-module azurerm.applicationinsights

Login-AzureRmAccount
Set-AzureRmContext -SubscriptionName "yoursubscription here"

$ai = Get-AzureRmApplicationInsights | select ResourceGroupName, Name

$AI | foreach {
    $cap = 1
    $color = 'red'
    if($_.Name -match 'dev'){
        $cap = .12
        $color = 'green'
    }
    if($_.Name -match 'stg'){
        $cap = .24
        $color = 'blue'
    }
    if($cap -eq 1)
    {
        if($_.Name -match 'api'){
            $cap = 1.4
            $color = 'yellow'
        }
        else{$cap = 2.9}
    }
    
    write-host ("Attempting to set daily cap at $cap for {0} instance " -f $_.ResourceGroupName) -NoNewline
    write-host $_.Name -ForegroundColor $color
    Set-AzureRmApplicationInsightsDailyCap -ResourceGroupName $_.ResourceGroupName -Name $_.Name -DailyCapGB $cap
}