Edit

Set-AzAppServicePlan

Sets an Azure App Service plan.

Syntax

S1

Set-AzAppServicePlan
    [[-AdminSiteName] <String>]
    [[-Tier] <String>]
    [[-NumberofWorkers] <Int32>]
    [[-WorkerSize] <String>]
    [-ResourceGroupName] <String>
    [-Name] <String>
    [-PerSiteScaling <Boolean>]
    [-AsyncScalingEnabled <Boolean>]
    [-AsJob]
    [-Tag <Hashtable>]
    [-AssignIdentity <Boolean>]
    [-UserAssignedIdentityId <String[]>]
    [-DefaultIdentity <String>]
    [-RdpEnabled <Boolean>]
    [-VirtualNetworkSubnetId <String>]
    [-InstallScript <InstallScript[]>]
    [-StorageMount <StorageMount[]>]
    [-RegistryAdapter <RegistryAdapter[]>]
    [-DefaultProfile <IAzureContextContainer>]
    [-AcquirePolicyToken]
    [-ChangeReference <String>]
    [<CommonParameters>]

S2

Set-AzAppServicePlan
    [-AppServicePlan] <PSAppServicePlan>
    [-AsyncScalingEnabled <Boolean>]
    [-AsJob]
    [-DefaultProfile <IAzureContextContainer>]
    [-AssignIdentity <Boolean>]
    [-UserAssignedIdentityId <String[]>]
    [-DefaultIdentity <String>]
    [-RdpEnabled <Boolean>]
    [-VirtualNetworkSubnetId <String>]
    [-InstallScript <InstallScript[]>]
    [-StorageMount <StorageMount[]>]
    [-RegistryAdapter <RegistryAdapter[]>]
    [-AcquirePolicyToken]
    [-ChangeReference <String>]
    [<CommonParameters>]

Description

The Set-AzAppServicePlan cmdlet sets an Azure App Service plan.

Use -AsyncScalingEnabled $true to allow asynchronous scaling when there are insufficient workers to scale synchronously, or -AsyncScalingEnabled $false to disable it. This setting requires a dedicated App Service plan. Omit the parameter to preserve the existing setting, including when passing a plan through the pipeline. The cmdlet waits for the operation to complete; use -AsJob for background execution.

For Managed Instance plans, this cmdlet also configures managed identities, installation scripts, storage mounts, registry adapters, plan-level virtual network integration, and Remote Desktop Protocol (RDP) access. Settings omitted from the command are preserved. Collection parameters replace the entire corresponding collection; pass an empty array to remove all entries. To add or remove a single entry, retrieve the existing plan and pass the updated collection.

Examples

Example 1: Modify an App Service plan

Set-AzAppServicePlan -ResourceGroupName "Default-Web-WestUS" -Name "ContosoASP" -PerSiteScaling $true

This command sets the PerSiteScaling option to true on the App Service plan named ContosoASP that belongs to the resource group named Default-Web-WestUS.

Example 2

Sets an Azure App Service plan. (autogenerated)

Set-AzAppServicePlan -Name 'ContosoASP' -ResourceGroupName 'Default-Web-WestUS' -Tier Free -WorkerSize Small

Example 3: Change an App Service plan to a memory-optimized Isolated v4 SKU

Set-AzAppServicePlan -ResourceGroupName "Default-Web-WestUS" -Name "ContosoASP" -Tier "IsolatedMV4" -WorkerSize "ExtraExtraLarge"

This command changes an App Service plan in an App Service Environment to the I5MV4 memory-optimized SKU.

Example 4: Update managed identities and disable RDP

$identityId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ContosoRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ContosoIdentity"
Set-AzAppServicePlan -ResourceGroupName "ContosoRG" -Name "ContosoManagedPlan" -UserAssignedIdentityId $identityId -DefaultIdentity $identityId -RdpEnabled $false

This command replaces the user-assigned identity list, selects that identity for plan integrations, and disables RDP. The system-assigned identity and other settings are preserved because their parameters were not specified.

Example 5: Remove one installation script without removing other scripts

$plan = Get-AzAppServicePlan -ResourceGroupName "ContosoRG" -Name "ContosoManagedPlan"
$scripts = @($plan.InstallScripts | Where-Object { $_.Name -ne "setup" })
Set-AzAppServicePlan -ResourceGroupName "ContosoRG" -Name "ContosoManagedPlan" -InstallScript $scripts

This command removes the setup script and retains the other scripts in their existing order. If setup was the last script, passing the empty array clears the script collection. To add a script, pass the existing collection together with the new script object.

Example 6: Clear Managed Instance configuration using pipeline input

Get-AzAppServicePlan -ResourceGroupName "ContosoRG" -Name "ContosoManagedPlan" |
    Set-AzAppServicePlan -InstallScript @() -StorageMount @() -RegistryAdapter @() -VirtualNetworkSubnetId "" -DefaultIdentity "" -AssignIdentity $false -UserAssignedIdentityId @()

This command removes all scripts, mounts, registry adapters, virtual network integration, and managed identities from the plan. The default identity is also cleared. Other properties, including whether the plan is a Managed Instance plan, are preserved.

Example 7: Enable asynchronous scaling while increasing the worker count

Set-AzAppServicePlan -ResourceGroupName "ContosoRG" -Name "ContosoASP" -NumberofWorkers 10 -AsyncScalingEnabled $true

This command enables asynchronous scaling on an existing dedicated App Service plan and requests ten workers. If there are insufficient workers to scale synchronously, the service scales asynchronously and the cmdlet waits for completion.

Parameters

-AcquirePolicyToken

Acquire an Azure Policy token automatically for this resource operation.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AdminSiteName

Admin Site Name

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

S1
Position:2
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AppServicePlan

App Service Plan Object

Parameter properties

Type:PSAppServicePlan
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

S2
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-AsJob

Run cmdlet in the background

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AssignIdentity

Enable or disable the plan's system-assigned managed identity. Omit this parameter to preserve the current system-assigned identity. User-assigned identities are preserved unless -UserAssignedIdentityId is also specified.

Parameter properties

Type:Boolean
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AsyncScalingEnabled

Enable or disable asynchronous scaling for a dedicated App Service plan. Set to true to allow an asynchronous operation when there are insufficient workers to scale synchronously, or false to allow only synchronous scaling. Omit this parameter to preserve the current setting. This parameter can also override the setting on a plan passed through the pipeline and is independent of -AsJob.

Parameter properties

Type:

Nullable<T>[Boolean]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ChangeReference

The change reference resource ID for this resource operation.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultIdentity

The identity used by default for plan integrations. Specify [system] for the system-assigned identity or the resource ID of a user-assigned identity associated with the plan. Pass an empty string to clear the default, including when removing the identity previously selected as the default. Omit the parameter to preserve the current default.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-InstallScript

The complete installation script collection for the Managed Instance plan. Each object specifies Name and a Source containing SourceUri and Type, such as RemoteAzureBlob or PlatformStorage. Pass an empty array to remove all scripts; omit the parameter to preserve existing scripts.

Parameter properties

Type:

InstallScript[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

App Service Plan Name

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

S1
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-NumberofWorkers

Number Of Workers

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

S1
Position:4
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PerSiteScaling

Per Site Scaling Boolean

Parameter properties

Type:Boolean
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

S1
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-RdpEnabled

Enable or disable Remote Desktop Protocol (RDP) access to the Managed Instance plan. Pass false to disable access; omit the parameter to preserve the current setting. Use Get-AzAppServicePlanRdpCredential to retrieve credentials when RDP is enabled.

Parameter properties

Type:Boolean
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-RegistryAdapter

The complete registry adapter collection for the Managed Instance plan. Each object specifies RegistryKey, Type, and KeyVaultSecretReference.SecretUri. Supported types include Binary, String, Expand_String, Multi_String, DWord, and QWord. Pass an empty array to remove all adapters; omit the parameter to preserve existing adapters.

Parameter properties

Type:

RegistryAdapter[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ResourceGroupName

Resource Group Name

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

S1
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-StorageMount

The complete storage mount collection for the Managed Instance plan. Each object specifies Name, Type, and DestinationPath. AzureFiles and FileShare mounts also require Source and can reference credentials with CredentialsKeyVaultReference.SecretUri. LocalStorage mounts do not require a source. Pass an empty array to remove all mounts; omit the parameter to preserve existing mounts.

Parameter properties

Type:

StorageMount[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Tag

Tags are name/value pairs that enable you to categorize resources

Parameter properties

Type:Hashtable
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

S1
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Tier

The App Service plan tier. Use IsolatedV4 for I1V4 through I6V4 plans and IsolatedMV4 for I1MV4 through I5MV4 memory-optimized plans in an App Service Environment.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

S1
Position:3
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-UserAssignedIdentityId

The complete list of user-assigned managed identity resource IDs to associate with the plan. Pass an empty array to remove all user-assigned identities; omit the parameter to preserve the current list. The system-assigned identity is preserved unless -AssignIdentity is also specified.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-VirtualNetworkSubnetId

The full resource ID of an existing subnet configured for App Service integration, including delegation to Microsoft.Web/serverFarms. Pass an empty string to disconnect the plan from its subnet; omit the parameter to preserve the current integration.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WorkerSize

The size of the workers to allocate. For IsolatedV4, Small through ExtraExtraExtraLarge select I1V4 through I6V4. For IsolatedMV4, Small through ExtraExtraLarge select I1MV4 through I5MV4.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

S1
Position:5
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

PSAppServicePlan

Outputs

PSAppServicePlan