Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.26k stars 3.86k forks source link

Enable-AzStorageStaticWebsite requires optional arguments #9473

Closed tjgalama closed 5 years ago

tjgalama commented 5 years ago

Description

the method Enable-AzStorageStaticWebsite has arguments IndexDocument and ErrorDocument404Path which are required. This is in contrast with the behavior within the azure portal when enabling a static website where these argument are optional.

Steps to reproduce

$portalStorageAccount = (Get-AzureRmStorageAccount | Where-Object { $_.StorageAccountName -eq 'mystorageweb01' })
Enable-AzureRmStorageStaticWebsite -Context $portalStorageAccount.Context -Verbose

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.1
PSEdition                      Core
GitCommitId                    6.2.1
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    Name                                PSEdition
---------- -------    ----                                ---------
Script     2.3.2      Az                                  Core,Desk
Script     1.5.3      Az.Accounts                         Core,Desk
Script     1.0.1      Az.Aks                              Core,Desk
Script     1.1.0      Az.AnalysisServices                 Core,Desk
Script     1.1.0      Az.ApiManagement                    Core,Desk
Script     1.0.0      Az.ApplicationInsights              Core,Desk
Script     1.2.2      Az.Automation                       Core,Desk
Script     1.1.0      Az.Batch                            Core,Desk
Script     1.0.0      Az.Billing                          Core,Desk
Script     1.3.0      Az.Cdn                              Core,Desk
Script     1.1.1      Az.CognitiveServices                Core,Desk
Script     2.3.0      Az.Compute                          Core,Desk
Script     1.0.1      Az.ContainerInstance                Core,Desk
Script     1.0.1      Az.ContainerRegistry                Core,Desk
Script     1.1.1      Az.DataFactory                      Core,Desk
Script     1.0.0      Az.DataLakeAnalytics                Core,Desk
Script     1.2.1      Az.DataLakeStore                    Core,Desk
Script     1.0.0      Az.DeploymentManager                Core,Desk
Script     1.0.0      Az.DevTestLabs                      Core,Desk
Script     1.1.1      Az.Dns                              Core,Desk
Script     1.2.0      Az.EventGrid                        Core,Desk
Script     1.2.0      Az.EventHub                         Core,Desk
Script     1.1.0      Az.FrontDoor                        Core,Desk
Script     2.0.0      Az.HDInsight                        Core,Desk
Script     1.1.0      Az.IotHub                           Core,Desk
Script     1.2.0      Az.KeyVault                         Core,Desk
Script     1.2.1      Az.LogicApp                         Core,Desk
Script     1.1.0      Az.MachineLearning                  Core,Desk
Script     1.0.0      Az.MarketplaceOrdering              Core,Desk
Script     1.1.0      Az.Media                            Core,Desk
Script     1.2.1      Az.Monitor                          Core,Desk
Script     1.10.0     Az.Network                          Core,Desk
Script     1.1.0      Az.NotificationHubs                 Core,Desk
Script     1.3.0      Az.OperationalInsights              Core,Desk
Script     1.1.1      Az.PolicyInsights                   Core,Desk
Script     1.1.0      Az.PowerBIEmbedded                  Core,Desk
Script     1.4.1      Az.RecoveryServices                 Core,Desk
Script     1.1.0      Az.RedisCache                       Core,Desk
Script     1.0.1      Az.Relay                            Core,Desk
Script     1.5.0      Az.Resources                        Core,Desk
Script     1.2.0      Az.ServiceBus                       Core,Desk
Script     1.1.1      Az.ServiceFabric                    Core,Desk
Script     1.0.2      Az.SignalR                          Core,Desk
Script     1.12.0     Az.Sql                              Core,Desk
Script     1.4.0      Az.Storage                          Core,Desk
Script     1.0.0      Az.StreamAnalytics                  Core,Desk
Script     1.0.1      Az.TrafficManager                   Core,Desk
Script     1.3.0      Az.Websites                         Core,Desk

    Directory: C:\program files\powershell\6\Modules

ModuleType Version    Name                                PSEdition
---------- -------    ----                                ---------
Manifest   6.1.0.0    CimCmdlets                          Core
Manifest   1.2.3.0    Microsoft.PowerShell.Archive        Desk
Manifest   6.1.0.0    Microsoft.PowerShell.Diagnostics    Core
Manifest   6.1.0.0    Microsoft.PowerShell.Host           Core
Manifest   6.1.0.0    Microsoft.PowerShell.Management     Core
Manifest   6.1.0.0    Microsoft.PowerShell.Security       Core
Manifest   6.1.0.0    Microsoft.PowerShell.Utility        Core
Manifest   6.1.0.0    Microsoft.WSMan.Management          Core
Script     1.3.2      PackageManagement                   Desk
Script     2.1.3      PowerShellGet                       Desk
Script     0.0        PSDesiredStateConfiguration         Desk
Script     6.1.0.0    PSDiagnostics                       Core
Script     2.0.0      PSReadLine                          Desk
Binary     1.1.2      ThreadJob                           Desk

    Directory: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

ModuleType Version    Name                                PSEdition
---------- -------    ----                                ---------
Manifest   1.0.0.0    AppBackgroundTask                   Core,Desk
Manifest   2.0.1.0    Appx                                Core,Desk
Script     1.0.0.0    AssignedAccess                      Core,Desk
Manifest   1.0.0.0    BitLocker                           Core,Desk
Manifest   1.0.0.0    BranchCache                         Core,Desk
Manifest   1.0        Defender                            Core,Desk
Manifest   1.0.2.0    DeliveryOptimization                Core,Desk
Manifest   1.0.0.0    DirectAccessClientComponents        Core,Desk
Script     3.0        Dism                                Core,Desk
Manifest   1.0.0.0    DnsClient                           Core,Desk
Manifest   1.0.0.0    EventTracingManagement              Core,Desk
Manifest   1.0.0.0    HgsClient                           Core,Desk
Manifest   1.0.0.0    HgsDiagnostics                      Core,Desk
Binary     2.0.0.0    Hyper-V                             Core,Desk
Binary     1.1        Hyper-V                             Core,Desk
Manifest   2.0.0.0    International                       Core,Desk
Manifest   3.0.0.0    Microsoft.PowerShell.Diagnostics    Core,Desk
Manifest   1.0.0.0    Microsoft.PowerShell.LocalAccounts  Core,Desk
Manifest   3.1.0.0    Microsoft.PowerShell.Management     Core,Desk
Manifest   1.0        MMAgent                             Core,Desk
Manifest   2.0.0.0    NetAdapter                          Core,Desk
Manifest   1.0.0.0    NetConnection                       Core,Desk
Manifest   1.0.0.0    NetEventPacketCapture               Core,Desk
Manifest   2.0.0.0    NetLbfo                             Core,Desk
Manifest   1.0.0.0    NetNat                              Core,Desk
Manifest   2.0.0.0    NetQos                              Core,Desk
Manifest   2.0.0.0    NetSecurity                         Core,Desk
Manifest   1.0.0.0    NetSwitchTeam                       Core,Desk
Manifest   1.0.0.0    NetTCPIP                            Core,Desk
Manifest   1.0.0.0    NetworkConnectivityStatus           Core,Desk
Manifest   1.0.0.0    NetworkSwitchManager                Core,Desk
Manifest   1.0.0.0    NetworkTransition                   Core,Desk
Manifest   1.0.0.0    PcsvDevice                          Core,Desk
Manifest   1.0.0.0    PnpDevice                           Core,Desk
Manifest   1.1        PrintManagement                     Core,Desk
Binary     1.0.11     ProcessMitigations                  Core,Desk
Manifest   1.0.0.0    ScheduledTasks                      Core,Desk
Manifest   2.0.0.0    SecureBoot                          Core,Desk
Manifest   2.0.0.0    SmbShare                            Core,Desk
Manifest   2.0.0.0    SmbWitness                          Core,Desk
Manifest   1.0.0.0    StartLayout                         Core,Desk
Manifest   2.0.0.0    Storage                             Core,Desk
Manifest   1.0.0.0    TroubleshootingPack                 Core,Desk
Manifest   2.0.0.0    TrustedPlatformModule               Core,Desk
Binary     2.1.639.0  UEV                                 Core,Desk
Manifest   2.0.0.0    VpnClient                           Core,Desk
Manifest   1.0.0.0    Wdac                                Core,Desk
Manifest   2.0.0.0    Whea                                Core,Desk
Manifest   1.0.0.0    WindowsDeveloperLicense             Core,Desk
Script     1.0        WindowsErrorReporting               Core,Desk
Manifest   1.0.0.0    WindowsSearch                       Core,Desk
Manifest   1.0.0.0    WindowsUpdate                       Core,Desk
Manifest   1.0.0.2    WindowsUpdateProvider               Core,Desk

Debug output

cmdlet Enable-AzStorageStaticWebsite at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
IndexDocument:
ErrorDocument404Path:
Enable-AzStorageStaticWebsite : Cannot bind argument to parameter 'IndexDocument' because it is an empty string.
At line:1 char:1
+ Enable-AzStorageStaticWebsite -Context $portalStorageAccount.Context  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidData: (:) [Enable-AzStorageStaticWebsite], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet.EnableAzureStorageServiceStaticWebsiteCommand

Error output

   HistoryId: 7
Message        : Cannot bind argument to parameter 'IndexDocument' because it is an empty string.
StackTrace     :    at System.Management.Automation.ParameterBinderBase.ValidateNullOrEmptyArgument(CommandParameterInt
                 ernal parameter, CompiledCommandParameter parameterMetadata, Type argumentType, Object parameterValue,
                  Boolean recurseIntoCollections)
                    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal paramete
                 r, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInter
                 nal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets,
                  CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags fl
                 ags)
                    at System.Management.Automation.ParameterBinderController.BindParameter(CommandParameterInternal ar
                 gument, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.HandleUnboundMandatoryParameters(In
                 t32 validParameterSetCount, Boolean processMissingMandatory, Boolean promptForMandatory, Boolean isPip
                 elineInputExpected, Collection`1& missingMandatoryParameters)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collectio
                 n`1 arguments)
                    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
                    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues
                 )
                    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input
                 )
                 --- End of stack trace from previous location where exception was thrown ---
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input
                 )
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, Comma
                 ndParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] command
                 Redirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame fr
                 ame)
Exception      : System.Management.Automation.ParameterBindingValidationException
InvocationInfo : {Enable-AzStorageStaticWebsite}
Line           : Enable-AzStorageStaticWebsite -Context $portalStorageAccount.Context -Verbose
Position       : At line:1 char:1
                 + Enable-AzStorageStaticWebsite -Context $portalStorageAccount.Context  ...
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 7
blueww commented 5 years ago

@tjgalama Thanks for raising this! Per the rest doc, the 2 parameter should be optional. I will try to fix Powershell soon.

tjgalama commented 5 years ago

I think the cause might be deeper than Az.Storage. I just tried to call the api directly (see stackoverflow). I got the impression that also the api requires these arguments (confirm?).

blueww commented 5 years ago

Per the rest doc, the 2 parameters are optional, so I have raised a PR to change them optional, and the PR is already merged. (I also tested PSH, enable Static WebSite without the 2 parameter success in server.) So from next release, PSH will be aligned with rest design. I will close the issue now. Feel free to let us know if you need any further assistant.