Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AppService]: fix #21153 Perform an App Service soft restart #21223

Merged
merged 2 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Websites/Websites/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Added a new parametre `-SoftRestart` for `Restart-AzWebApp` and `Restart-AzWebApp` to perform a soft restart
* Updated `Get-AzWebApp` and `Get-AzWebAppSlot` to expose `VirtualNetwork Integration Info` [#10665]
* Added a new parameter `-CopyIdentity` for `New-AzWebAppSlot` to copy the identity from the parent app to the slot.
* Updated `New-AzWebAppSSLBinding` to support -WhatIf parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ namespace Microsoft.Azure.Commands.WebApps.Cmdlets.DeploymentSlots
[Cmdlet("Restart", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "WebAppSlot"), OutputType(typeof(PSSite))]
public class RestartAzureWebAppSlotCmdlet : WebAppSlotBaseCmdlet
{
[Parameter(Mandatory = false, HelpMessage = "Specify true to apply the configuration settings and restarts the app only if necessary.")]
public SwitchParameter SoftRestart { get; set; }
public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
WebsitesClient.RestartWebApp(ResourceGroupName, Name, Slot);
WebsitesClient.RestartWebApp(ResourceGroupName, Name, Slot, SoftRestart);
WriteObject(new PSSite(WebsitesClient.GetWebApp(ResourceGroupName, Name, Slot)));
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Websites/Websites/Cmdlets/WebApps/RestartAzureWebApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ namespace Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps
[Cmdlet("Restart", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "WebApp"), OutputType(typeof(PSSite))]
public class RestartAzureWebAppCmdlet : WebAppBaseCmdlet
{
[Parameter(Mandatory = false, HelpMessage = "Specify true to apply the configuration settings and restarts the app only if necessary.")]
public SwitchParameter SoftRestart { get; set; }
public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
WebsitesClient.RestartWebApp(ResourceGroupName, Name, null);
WebsitesClient.RestartWebApp(ResourceGroupName, Name, null, SoftRestart);
WriteObject(new PSSite(WebsitesClient.GetWebApp(ResourceGroupName, Name, null)));
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Websites/Websites/Utilities/WebsitesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,16 @@ public void StopWebApp(string resourceGroupName, string webSiteName, string slot
WrappedWebsitesClient.WebApps().Stop(resourceGroupName, webSiteName);
}
}
public void RestartWebApp(string resourceGroupName, string webSiteName, string slotName)
public void RestartWebApp(string resourceGroupName, string webSiteName, string slotName, bool softRestart)
{
string qualifiedSiteName;
if (CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName))
{
WrappedWebsitesClient.WebApps().RestartSlot(resourceGroupName, webSiteName, slotName);
WrappedWebsitesClient.WebApps().RestartSlot(resourceGroupName, webSiteName, slotName, softRestart);
}
else
{
WrappedWebsitesClient.WebApps().Restart(resourceGroupName, webSiteName);
WrappedWebsitesClient.WebApps().Restart(resourceGroupName, webSiteName, softRestart);
}
}

Expand Down
20 changes: 18 additions & 2 deletions src/Websites/Websites/help/Restart-AzWebApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Restarts an Azure Web App.

### S1
```
Restart-AzWebApp [-ResourceGroupName] <String> [-Name] <String> [-DefaultProfile <IAzureContextContainer>]
Restart-AzWebApp [-ResourceGroupName] <String> [-Name] <String> [-SoftRestart] [-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
```

### S2
```
Restart-AzWebApp [-WebApp] <PSSite> [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
Restart-AzWebApp [-WebApp] <PSSite> [-SoftRestart] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -84,6 +84,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -SoftRestart
Specify true to apply the configuration settings and restarts the app only if necessary.
By default, the API always restarts and reprovisions the app.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -WebApp
WebApp Object

Expand Down
22 changes: 19 additions & 3 deletions src/Websites/Websites/help/Restart-AzWebAppSlot.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ schema: 2.0.0
# Restart-AzWebAppSlot

## SYNOPSIS

Restarts an Azure Web App Slot.
## SYNTAX

### S1
```
Restart-AzWebAppSlot [-ResourceGroupName] <String> [-Name] <String> [-Slot] <String>
Restart-AzWebAppSlot [-ResourceGroupName] <String> [-Name] <String> [-Slot] <String> [-SoftRestart]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

### S2
```
Restart-AzWebAppSlot [-WebApp] <PSSite> [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
Restart-AzWebAppSlot [-WebApp] <PSSite> [-SoftRestart] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -98,6 +98,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -SoftRestart
Specify true to apply the configuration settings and restarts the app only if necessary.
By default, the API always restarts and reprovisions the app.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -WebApp
WebApp Object

Expand Down