Skip to content

Commit 867e18c

Browse files
committed
[Storage] Set StaticWebsite properties IndexDocument and ErrorDocument404Path to optional.
1 parent e6e3251 commit 867e18c

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/Storage/Storage.Management/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Change 2 parameters "-IndexDocument" and "-ErrorDocument404Path" from required to optional in cmdlet:
22+
- Enable-AzStorageStaticWebsite
2123
* Show more error information when cmdlet failed with StorageException
2224

2325
## Version 1.4.0

src/Storage/Storage.Management/help/Enable-AzStorageStaticWebsite.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
external help file: Microsoft.Azure.PowerShell.Cmdlets.Storage.dll-Help.xml
33
Module Name: Az.Storage
44
online version: https://docs.microsoft.com/en-us/powershell/module/az.storage/enable-azstoragestaticwebsite
@@ -13,7 +13,7 @@ Enable static website for the Azure Storage account.
1313
## SYNTAX
1414

1515
```
16-
Enable-AzStorageStaticWebsite [-IndexDocument] <String> [-ErrorDocument404Path] <String> [-PassThru]
16+
Enable-AzStorageStaticWebsite [[-IndexDocument] <String>] [[-ErrorDocument404Path] <String>] [-PassThru]
1717
[-Context <IStorageContext>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
1818
[<CommonParameters>]
1919
```
@@ -70,7 +70,7 @@ Type: System.String
7070
Parameter Sets: (All)
7171
Aliases:
7272

73-
Required: True
73+
Required: False
7474
Position: 1
7575
Default value: None
7676
Accept pipeline input: False
@@ -85,15 +85,15 @@ Type: System.String
8585
Parameter Sets: (All)
8686
Aliases:
8787

88-
Required: True
88+
Required: False
8989
Position: 0
9090
Default value: None
9191
Accept pipeline input: False
9292
Accept wildcard characters: False
9393
```
9494
9595
### -PassThru
96-
{{Fill PassThru Description}}
96+
Display Static Website setting in ServiceProperties.
9797
9898
```yaml
9999
Type: System.Management.Automation.SwitchParameter

src/Storage/Storage/Common/Cmdlet/EnableAzureStorageStaticWebsite.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet
2727
OutputType(typeof(PSStaticWebsiteProperties))]
2828
public class EnableAzureStorageServiceStaticWebsiteCommand : StorageCloudBlobCmdletBase
2929
{
30-
[Parameter(Mandatory = true, Position = 0, HelpMessage = "The name of the index document in each directory.")]
30+
[Parameter(Mandatory = false, Position = 0, HelpMessage = "The name of the index document in each directory.")]
31+
[ValidateNotNull]
3132
public string IndexDocument { get; set; }
3233

33-
[Parameter(Mandatory = true, Position = 1, HelpMessage = "the path to the error document that should be shown when a 404 is issued (meaning, when a browser requests a page that does not exist.)")]
34+
[Parameter(Mandatory = false, Position = 1, HelpMessage = "the path to the error document that should be shown when a 404 is issued (meaning, when a browser requests a page that does not exist.)")]
35+
[ValidateNotNull]
3436
public string ErrorDocument404Path { get; set; }
3537

3638
[Parameter(Mandatory = false)]
@@ -57,8 +59,14 @@ internal void EnableStaticWebsiteProperties(ServiceProperties serviceProperties)
5759
serviceProperties.StaticWebsite = new StaticWebsiteProperties();
5860
}
5961
serviceProperties.StaticWebsite.Enabled = true;
60-
serviceProperties.StaticWebsite.IndexDocument = this.IndexDocument;
61-
serviceProperties.StaticWebsite.ErrorDocument404Path = this.ErrorDocument404Path;
62+
if (this.IndexDocument != null)
63+
{
64+
serviceProperties.StaticWebsite.IndexDocument = this.IndexDocument;
65+
}
66+
if (this.ErrorDocument404Path != null)
67+
{
68+
serviceProperties.StaticWebsite.ErrorDocument404Path = this.ErrorDocument404Path;
69+
}
6270
}
6371

6472
/// <summary>

0 commit comments

Comments
 (0)