How to set CooldownPeriod for New-AzContainerAppScaleRuleObject via Powershell CLI

Brian Bento 0 Reputation points
2026-09-14T16:48:32.51+00:00

I am setting up a new AppScaleRule for my container app but there is no documentation on how to set the cooldown period at all.

Here is part of script:

$scaleRule = New-AzContainerAppScaleRuleObject -Name "http-scaling-rule" -CustomType "http" -CustomMetadata @{"concurrentRequests"="1"}

$containerApp = @{

	ResourceGroupName = $resourceGroupName 

	SubscriptionId = $subscriptionId 

	Name = $service 

	Location = "centralus" 

	TemplateContainer = @($template)

	ManagedEnvironmentId = $managedEnvId		

	Configuration = $appConfig

	ScaleMinReplica = 0

	ScaleMaxReplica = 1

	ScaleRule = @($scaleRule)

}	

New-AzContainerApp @containerApp

I have checked everywhere and there is no documentation on it - I assumed it would be at the same level as the ScaleMinReplica and ScaleMaxReplica because that is how it shows up in the UI but it doesn't exist on that in the documentation.

Azure Container Apps
Azure Container Apps

An Azure service that provides a general-purpose, serverless container platform.


1 answer

Sort by: Newest
  1. Allan Solomon Mejia 9,485 Reputation points
    2026-09-14T19:39:27.49+00:00

    Hello @Brian Bento

    You're looking in the right general area, but cooldownPeriod isn't actually a property of New AzContainerAppScaleRuleObject.

    In the Azure Container Apps resource model, the structure is:

    User's image

    So cooldownPeriod applies to the Container App scaling configuration, not to an individual scaling rule. Microsoft currently documents it as an optional integer in seconds, with a default of 300 seconds when it isn't specified.

    That's why you don't see a -CooldownPeriod parameter on:

    New-AzContainerAppScaleRuleObject
    

    Your $scaleRule construction is therefore only defining the rule itself:

    $scaleRule = New-AzContainerAppScaleRuleObject `
        -Name "http-scaling-rule" `
        -CustomType "http" `
        -CustomMetadata @{"concurrentRequests"="1"}
    

    The problem is that the current New-AzContainerApp PowerShell parameter set you're using exposes things such as ScaleMinReplica, ScaleMaxReplica, and ScaleRule, but doesn't expose the complete underlying template.scale model, including cooldownPeriod.

    The ARM resource schema does expose it:

    "template": {
      "scale": {
        "minReplicas": 0,
        "maxReplicas": 1,
        "cooldownPeriod": 60,
        "rules": [
          ...
        ]
      }
    }
    

    Microsoft documents that schema here:

    Microsoft.App/containerApps ARM/Bicep reference

    So if the Az PowerShell cmdlet/version you're using doesn't expose ScaleCooldownPeriod, don't put it in CustomMetadata. That metadata belongs to the scaler itself and isn't where Container Apps expects the KEDA cooldown setting.

    Instead, use the ARM/Bicep representation (or another deployment method that exposes the complete template.scale object) and set: properties.template.scale.cooldownPeriod

    For example, in Bicep:

    template: {
      scale: {
        minReplicas: 0
        maxReplicas: 1
        cooldownPeriod: 60
        rules: [
          // scaling rule
        ]
      }
    }
    

    There is also a pollingInterval property at the same level if you need to control how frequently KEDA evaluates non-HTTP event sources; its documented default is 30 seconds.

    So your assumption from the portal was correct: Cooldown Period belongs at the same logical scale level as Min Replicas and Max Replicas, not inside New-AzContainerAppScaleRuleObject. The confusing part is simply that the Az.ContainerApp PowerShell cmdlet doesn't necessarily expose every property available in the current Container Apps ARM schema.

    If PowerShell is mandatory for your deployment pipeline, you can still deploy/update the ARM resource from PowerShell rather than relying exclusively on New-AzContainerApp's flattened parameters.


    Help make this community better for everyone: If this answer helped or resolved your issue, please accept it or upvote it. If not, share more details in a comment so we can continue the discussion and find the right solution. Thank you.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.