Skip to content

Commit 884d4b1

Browse files
[AppService]: fix #16816- New-AzWebAppSSLBinding is missing the -WhatIf parameter (#20941)
* [AppService]: fix #16816- New-AzWebAppSSLBinding is missing the -WhatIf parameter * ReRecorded the failed tests * Updated changelog.md
1 parent 1a4a204 commit 884d4b1

File tree

10 files changed

+5888
-4954
lines changed

10 files changed

+5888
-4954
lines changed

src/Websites/Websites.Test/ScenarioTests/SSLBindingTests.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ assign a custom domain to it and update global variable values.
1717
#>
1818

1919
#Global variables
20-
$rgname = "lketmtestantps10"
21-
$appname = "lketmtestantps10"
20+
$rgname = "RG-PS-UnitTesting"
21+
$appname = "AppService-PS-UnitTesting"
2222
$slot = "testslot"
23-
$prodHostname = "www.adorenow.net"
24-
$slotHostname = "testslot.adorenow.net"
25-
$thumbprint = "6156D1475113476C55A3064D44DED9ECA0B33864"
23+
$prodHostname = "www.psunittesting.com"
24+
$slotHostname = "testslot.psunittesting.com"
25+
$thumbprint = "210C5A1BBF7BC63F8733C3CB5E612FCFF3643E41"
2626

2727
<#
2828
.SYNOPSIS

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.SSLBindingTests/TagsNotRemovedByCreateNewWebAppSSLBinding.json

Lines changed: 1054 additions & 916 deletions
Large diffs are not rendered by default.

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.SSLBindingTests/TestCreateNewWebAppSSLBinding.json

Lines changed: 795 additions & 657 deletions
Large diffs are not rendered by default.

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.SSLBindingTests/TestGetNewWebAppSSLBinding.json

Lines changed: 1047 additions & 909 deletions
Large diffs are not rendered by default.

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.SSLBindingTests/TestGetWebAppCertificate.json

Lines changed: 578 additions & 371 deletions
Large diffs are not rendered by default.

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.SSLBindingTests/TestRemoveNewWebAppSSLBinding.json

Lines changed: 1047 additions & 909 deletions
Large diffs are not rendered by default.

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.SSLBindingTests/TestWebAppSSLBindingPipeSupport.json

Lines changed: 1318 additions & 1180 deletions
Large diffs are not rendered by default.

src/Websites/Websites/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Updated `New-AzWebAppSSLBinding` to support -WhatIf parameter
2122

2223
## Version 2.12.1
2324
* Fixed `Import-AzWebAppKeyVaultCertificate` to use certificate naming convention same as portal [#19592]

src/Websites/Websites/Cmdlets/Certificates/NewAzureWebAppSSLBinding.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps
2929
/// <summary>
3030
/// this commandlet will let you create a new Azure Web app using ARM APIs
3131
/// </summary>
32-
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "WebAppSSLBinding"), OutputType(typeof(HostNameSslState))]
32+
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "WebAppSSLBinding", SupportsShouldProcess = true), OutputType(typeof(HostNameSslState))]
3333
public class NewAzureWebAppSSLBinding : WebAppBaseClientCmdLet
3434
{
3535
const string CertNamePostFixSeparator = "_";
@@ -130,7 +130,10 @@ protected override void ProcessRecord()
130130

131131
try
132132
{
133-
Certificate cert= WebsitesClient.CreateCertificate(resourceGroupName, certificateName, certificate);
133+
if (this.ShouldProcess(this.WebAppName, string.Format("Creating a new certificate - '{0}' in Web Application - {1}.", certificateName, this.WebAppName)))
134+
{
135+
Certificate cert = WebsitesClient.CreateCertificate(resourceGroupName, certificateName, certificate);
136+
}
134137
}
135138
catch (CloudException e)
136139
{
@@ -149,8 +152,9 @@ protected override void ProcessRecord()
149152
thumbPrint = Thumbprint;
150153
break;
151154
}
152-
153-
WriteObject(CmdletHelpers.GetHostNameSslStatesFromSiteResponse(
155+
if (this.ShouldProcess(this.WebAppName, string.Format("Binding the certificate with thumbprint- '{0}' to Web Application - {1}.", thumbPrint, this.WebAppName)))
156+
{
157+
WriteObject(CmdletHelpers.GetHostNameSslStatesFromSiteResponse(
154158
WebsitesClient.UpdateHostNameSslState(
155159
resourceGroupName,
156160
webAppName,
@@ -160,6 +164,7 @@ protected override void ProcessRecord()
160164
SslState.HasValue ? SslState.Value : Management.WebSites.Models.SslState.SniEnabled,
161165
thumbPrint),
162166
Name));
167+
}
163168
}
164169

165170
private string GenerateCertName(string thumbPrint, string hostingEnv, string location, string resourceGroupName)

src/Websites/Websites/help/New-AzWebAppSSLBinding.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ Creates an SSL certificate binding for an Azure Web App.
1717
```
1818
New-AzWebAppSSLBinding [-ResourceGroupName] <String> [-WebAppName] <String> [[-Slot] <String>] [-Name] <String>
1919
[[-SslState] <SslState>] [-CertificateFilePath] <String> [-CertificatePassword] <String>
20-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
20+
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2121
```
2222

2323
### S2
2424
```
2525
New-AzWebAppSSLBinding [-ResourceGroupName] <String> [-WebAppName] <String> [[-Slot] <String>] [-Name] <String>
2626
[[-SslState] <SslState>] [-Thumbprint] <String> [-DefaultProfile <IAzureContextContainer>]
27-
[<CommonParameters>]
27+
[-WhatIf] [-Confirm] [<CommonParameters>]
2828
```
2929

3030
### S3
3131
```
3232
New-AzWebAppSSLBinding [-WebApp] <PSSite> [-Name] <String> [[-SslState] <SslState>]
3333
[-CertificateFilePath] <String> [-CertificatePassword] <String> [-DefaultProfile <IAzureContextContainer>]
34-
[<CommonParameters>]
34+
[-WhatIf] [-Confirm] [<CommonParameters>]
3535
```
3636

3737
### S4
@@ -117,6 +117,21 @@ Accept pipeline input: False
117117
Accept wildcard characters: False
118118
```
119119
120+
### -Confirm
121+
Prompts you for confirmation before running the cmdlet.
122+
123+
```yaml
124+
Type: System.Management.Automation.SwitchParameter
125+
Parameter Sets: (All)
126+
Aliases: cf
127+
128+
Required: False
129+
Position: Named
130+
Default value: None
131+
Accept pipeline input: False
132+
Accept wildcard characters: False
133+
```
134+
120135
### -DefaultProfile
121136
The credentials, account, tenant, and subscription used for communication with azure.
122137
@@ -246,6 +261,22 @@ Accept pipeline input: False
246261
Accept wildcard characters: False
247262
```
248263
264+
### -WhatIf
265+
Shows what would happen if the cmdlet runs.
266+
The cmdlet is not run.
267+
268+
```yaml
269+
Type: System.Management.Automation.SwitchParameter
270+
Parameter Sets: (All)
271+
Aliases: wi
272+
273+
Required: False
274+
Position: Named
275+
Default value: None
276+
Accept pipeline input: False
277+
Accept wildcard characters: False
278+
```
279+
249280
### CommonParameters
250281
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
251282

0 commit comments

Comments
 (0)