Editar

Partilhar via


Set-AzWebApp

Modifies an Azure Web App.

Syntax

Set-AzWebApp
   [[-AppServicePlan] <String>]
   [[-DefaultDocuments] <String[]>]
   [[-NetFrameworkVersion] <String>]
   [[-PhpVersion] <String>]
   [[-RequestTracingEnabled] <Boolean>]
   [[-HttpLoggingEnabled] <Boolean>]
   [[-DetailedErrorLoggingEnabled] <Boolean>]
   [[-AppSettings] <Hashtable>]
   [[-ConnectionStrings] <Hashtable>]
   [[-HandlerMappings] <System.Collections.Generic.IList`1[Microsoft.Azure.Management.WebSites.Models.HandlerMapping]>]
   [[-ManagedPipelineMode] <String>]
   [[-WebSocketsEnabled] <Boolean>]
   [[-Use32BitWorkerProcess] <Boolean>]
   [[-AutoSwapSlotName] <String>]
   [-ContainerImageName <String>]
   [-ContainerRegistryUrl <String>]
   [-ContainerRegistryUser <String>]
   [-ContainerRegistryPassword <SecureString>]
   [-EnableContainerContinuousDeployment <Boolean>]
   [-HostNames <String[]>]
   [-NumberOfWorkers <Int32>]
   [-AsJob]
   [-AssignIdentity <Boolean>]
   [-HttpsOnly <Boolean>]
   [-AzureStoragePath <WebAppAzureStoragePath[]>]
   [-AlwaysOn <Boolean>]
   [-MinTlsVersion <String>]
   [-FtpsState <String>]
   [-ResourceGroupName] <String>
   [-Name] <String>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Set-AzWebApp
   [[-Use32BitWorkerProcess] <Boolean>]
   [[-AutoSwapSlotName] <String>]
   [-NumberOfWorkers <Int32>]
   [-AsJob]
   [-WebApp] <PSSite>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The Set-AzWebApp cmdlet sets an Azure Web App.

Examples

Example 1

Set-AzWebApp -ResourceGroupName "Default-Web-WestUS" -Name "ContosoWebApp" -AppServicePlan "ContosoPlan"

This command changes the appservice plan associated with the Web App ContosoWebApp associated with the resource group Default-Web-WestUS. Use the link to learn more about changing the appservice plan and constraints associated with it. https://learn.microsoft.com/azure/app-service/app-service-plan-manage#move-an-app-to-another-app-service-plan

Example 2

Set-AzWebApp -ResourceGroupName "Default-Web-WestUS" -Name "ContosoWebApp" -HttpLoggingEnabled $true

This command sets HttpLoggingEnabled to true for Web App ContosoWebApp associated with the resource group Default-Web-WestUS

Example 3

Modifies an Azure Web App. (autogenerated)

Set-AzWebApp -AppSettings <Hashtable> -Name 'ContosoWebApp' -ResourceGroupName 'Default-Web-WestUS'

Example 4

The following example creates a connection string named myConnectionString for Web App ContosoWebApp. This replaces all existing connection strings for Web App ContosoWebApp.

$hashtable =  @{myConnectionString = @{Type='MySql';Value='MySql Connection string'}}
Set-AzWebApp -Name 'ContosoWebApp' -ResourceGroupName 'Default-Web-WestUS' -ConnectionStrings $hashtable

Example 5

Enable application insights for Web App

$key=(Get-AzApplicationInsights -ResourceId $ai).InstrumentationKey
$setting=@{"ApplicationInsightsAgent_EXTENSION_VERSION"="~3"; "APPINSIGHTS_INSTRUMENTATIONKEY"=$key}
Set-AzWebApp -AppSettings $setting -Name 'ContosoWebApp' -ResourceGroupName 'Default-Web-WestUS'

Parameters

-AlwaysOn

Ensure web app gets loaded all the time, rather unloaded after been idle.

Type:Boolean
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AppServicePlan

App Service Plan Name

Type:String
Position:2
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AppSettings

App Settings HashTable. Existing App Settings will be replaced, removing any settings that are not provided.

Type:Hashtable
Position:9
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AssignIdentity

Enable/disable MSI on an existing azure webapp or functionapp

Type:Boolean
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoSwapSlotName

Destination slot name for auto swap

Type:String
Position:15
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AzureStoragePath

Azure Storage to mount inside a Web App for Container. Use New-AzWebAppAzureStoragePath to create it

Type:WebAppAzureStoragePath[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ConnectionStrings

Connection Strings HashTable

Type:Hashtable
Position:10
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ContainerImageName

Container Image Name

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ContainerRegistryPassword

Private Container Registry Password

Type:SecureString
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ContainerRegistryUrl

Private Container Registry Server Url

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ContainerRegistryUser

Private Container Registry Username

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultDocuments

Default Documents String Array

Type:String[]
Position:3
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

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

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DetailedErrorLoggingEnabled

Detailed Error Logging Enabled Boolean

Type:Boolean
Position:8
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-EnableContainerContinuousDeployment

Enables/Disables container continuous deployment webhook

Type:Boolean
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-FtpsState

Set the Ftps state value for an app. Allowed Values [AllAllowed | Disabled | FtpsOnly].

Type:String
Accepted values:AllAllowed, Disabled, FtpsOnly
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-HandlerMappings

Handler Mappings IList

Type:IList<T>[HandlerMapping]
Position:11
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-HostNames

WebApp HostNames String Array

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-HttpLoggingEnabled

HttpLoggingEnabled Boolean

Type:Boolean
Position:7
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-HttpsOnly

Enable/disable redirecting all traffic to HTTPS on an existing azure webapp or functionapp

Type:Boolean
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ManagedPipelineMode

Managed Pipeline Mode Name

Type:String
Accepted values:Classic, Integrated
Position:12
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-MinTlsVersion

The minimum version of TLS required for SSL requests. Allowed Values [1.0 | 1.1 | 1.2].

Type:String
Accepted values:1.0, 1.1, 1.2
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Name

WebApp Name

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-NetFrameworkVersion

Net Framework Version

Type:String
Position:4
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-NumberOfWorkers

The number of workers to be allocated

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-PhpVersion

Php Version

Type:String
Position:5
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RequestTracingEnabled

Request Tracing Enabled

Type:Boolean
Position:6
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

Resource Group Name

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Use32BitWorkerProcess

Use 32-bit Worker Process Boolean

Type:Boolean
Position:14
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WebApp

WebApp Object

Type:PSSite
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WebSocketsEnabled

WebSocketsEnabled Boolean

Type:Boolean
Position:13
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Int32

String

PSSite

Outputs

PSSite

Notes

Below provided cmdlet will help you to update Azure Web App to DOTNETCORE $PropertiesObject = @{ "CURRENT_STACK" = "dotnetcore" } New-AzResource -PropertyObject $PropertiesObject -ResourceGroupName "Default-Web-WestUS" -ResourceType Microsoft.Web/sites/config -ResourceName "ContosoWebApp/metadata" -ApiVersion 2018-02-01 -Force Replace the values of Default-Web-WestUS with your resource group name of the webapp and ContosoWebApp with the webapp name.