Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.82k forks source link

The -Debug switch causes the -Confirm:$False switch to be ignored in Set-AzStorageBlobContent #15831

Open benrobot opened 3 years ago

benrobot commented 3 years ago

Description

The -Debug switch ~(as well as $DebugPreference='Continue')~ causes the -Confirm:$False switch to be ignored in Set-AzStorageBlobContent cmdlet. If this is desired behavior then maybe it should be documented on the troubleshooting page https://docs.microsoft.com/en-us/powershell/azure/troubleshooting?view=azps-6.4.0.

I'm using these cmdlets in my CI/CD pipeline (issue is reproduced both on the pipeline as well as on my local machine) and I like to have verbose output so I know exactly what happened should something go wrong. The behavior presented here prevents me from using the -Debug switch because the CI/CD pipeline throws an exception like PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.:

image

Steps to reproduce

Deploy.ps1 Deploy.ps1.txt

<#
    .EXAMPLE
    PS> .\Deploy.ps1 -resourceGroupName "myResourceGroup" -storageAccountName "mystorageaccount" -blobContainerName "myblobname" -someFilePath "./somefile.txt" *> almost_all_output.log
#>
param (   
    [Parameter(Mandatory=$true)][String]$resourceGroupName,
    [Parameter(Mandatory=$true)][String]$storageAccountName,
    [Parameter(Mandatory=$true)][String]$blobContainerName,
    [Parameter(Mandatory=$true)][String]$someFilePath
)
$DebugPreference='Continue'
$ErrorActionPreference = "Stop"

$storageAccount = Get-AzStorageAccount `
    -ResourceGroupName $resourceGroupName `
    -Name $storageAccountName

$storageAccountContext = $storageAccount.Context

Write-Host "Next command should NOT prompt but it does when given either -Debug or `$DebugPreference='Continue' is set"
Set-AzStorageBlobContent -Debug `
    -File $someFilePath `
    -Confirm:$False `
    -Container $blobContainerName `
    -Context $storageAccountContext

Environment data

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

Module versions


    Directory: C:\Users\REDACTED\Documents\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     6.3.0                 Az                                  Core,Desk
Script     2.5.2                 Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzContextAutosave, Enable-AzDataCollecti…
Script     1.1.1                 Az.Advisor                          Core,Desk {Get-AzAdvisorRecommendation, Enable-AzAdvisorRecommendation, Disable-AzAdv…
Script     2.3.0                 Az.Aks                              Core,Desk {Get-AzAksCluster, New-AzAksCluster, Remove-AzAksCluster, Import-AzAksCrede…
Script     1.1.4                 Az.AnalysisServices                 Core,Desk {Resume-AzAnalysisServicesServer, Suspend-AzAnalysisServicesServer, Get-AzA…
Script     2.2.0                 Az.ApiManagement                    Core,Desk {Add-AzApiManagementApiToGateway, Add-AzApiManagementApiToProduct, Add-AzAp…
Script     1.0.0                 Az.AppConfiguration                 Core,Desk {Get-AzAppConfigurationStore, Get-AzAppConfigurationStoreKey, New-AzAppConf…
Script     1.2.0                 Az.ApplicationInsights              Core,Desk {Get-AzApplicationInsights, New-AzApplicationInsights, Remove-AzApplication…
Script     1.7.0                 Az.Automation                       Core,Desk {Get-AzAutomationHybridWorkerGroup, Remove-AzAutomationHybridWorkerGroup, G…
Script     3.1.0                 Az.Batch                            Core,Desk {Remove-AzBatchAccount, Get-AzBatchAccount, Get-AzBatchAccountKey, New-AzBa…
Script     2.0.0                 Az.Billing                          Core,Desk {Get-AzBillingInvoice, Get-AzBillingPeriod, Get-AzEnrollmentAccount, Get-Az…
Script     1.7.1                 Az.Cdn                              Core,Desk {Get-AzCdnProfile, Get-AzCdnProfileSsoUrl, New-AzCdnProfile, Remove-AzCdnPr…
Script     1.9.0                 Az.CognitiveServices                Core,Desk {Get-AzCognitiveServicesAccount, Get-AzCognitiveServicesAccountKey, Get-AzC…
Script     4.16.0                Az.Compute                          Core,Desk {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAvailabilitySet, Up…
Script     2.1.0                 Az.ContainerInstance                Core,Desk {Add-AzContainerInstanceOutput, Get-AzContainerGroup, Get-AzContainerInstan…
Script     2.2.3                 Az.ContainerRegistry                Core,Desk {New-AzContainerRegistry, Get-AzContainerRegistry, Update-AzContainerRegist…
Script     1.3.0                 Az.CosmosDB                         Core,Desk {Get-AzCosmosDBSqlContainer, Get-AzCosmosDBSqlContainerThroughput, Get-AzCo…
Script     1.1.0                 Az.DataBoxEdge                      Core,Desk {Get-AzDataBoxEdgeJob, Get-AzDataBoxEdgeDevice, Invoke-AzDataBoxEdgeDevice,…
Script     1.1.0                 Az.Databricks                       Core,Desk {Get-AzDatabricksVNetPeering, Get-AzDatabricksWorkspace, New-AzDatabricksVN…
Script     1.13.1                Az.DataFactory                      Core,Desk {Set-AzDataFactoryV2, Update-AzDataFactoryV2, Get-AzDataFactoryV2, Remove-A…
Script     1.0.2                 Az.DataLakeAnalytics                Core,Desk {Get-AzDataLakeAnalyticsDataSource, New-AzDataLakeAnalyticsCatalogCredentia…
Script     1.3.0                 Az.DataLakeStore                    Core,Desk {Get-AzDataLakeStoreTrustedIdProvider, Remove-AzDataLakeStoreTrustedIdProvi…
Script     1.0.0                 Az.DataShare                        Core,Desk {New-AzDataShareAccount, Get-AzDataShareAccount, Remove-AzDataShareAccount,…
Script     1.1.0                 Az.DeploymentManager                Core,Desk {Get-AzDeploymentManagerArtifactSource, New-AzDeploymentManagerArtifactSour…
Script     3.0.0                 Az.DesktopVirtualization            Core,Desk {Disconnect-AzWvdUserSession, Expand-AzWvdMsixImage, Get-AzWvdApplication, …
Script     1.0.2                 Az.DevTestLabs                      Core,Desk {Get-AzDtlAllowedVMSizesPolicy, Get-AzDtlAutoShutdownPolicy, Get-AzDtlAutoS…
Script     1.1.2                 Az.Dns                              Core,Desk {Get-AzDnsRecordSet, New-AzDnsRecordConfig, Remove-AzDnsRecordSet, Set-AzDn…
Script     1.3.0                 Az.EventGrid                        Core,Desk {New-AzEventGridTopic, Get-AzEventGridTopic, Set-AzEventGridTopic, New-AzEv…
Script     1.8.0                 Az.EventHub                         Core,Desk {New-AzEventHubNamespace, Get-AzEventHubNamespace, Set-AzEventHubNamespace,…
Script     1.8.0                 Az.FrontDoor                        Core,Desk {New-AzFrontDoor, Get-AzFrontDoor, Set-AzFrontDoor, Remove-AzFrontDoor…}
Script     3.1.0                 Az.Functions                        Core,Desk {Get-AzFunctionApp, Get-AzFunctionAppAvailableLocation, Get-AzFunctionAppPl…
Script     4.3.0                 Az.HDInsight                        Core,Desk {Get-AzHDInsightJob, New-AzHDInsightSqoopJobDefinition, Wait-AzHDInsightJob…
Script     1.3.1                 Az.HealthcareApis                   Core,Desk {New-AzHealthcareApisService, Remove-AzHealthcareApisService, Set-AzHealthc…
Script     2.7.3                 Az.IotHub                           Core,Desk {Add-AzIotHubKey, Get-AzIotHubEventHubConsumerGroup, Get-AzIotHubConnection…
Script     3.4.5                 Az.KeyVault                         Core,Desk {Add-AzKeyVaultCertificate, Update-AzKeyVaultCertificate, Stop-AzKeyVaultCe…
Script     2.0.0                 Az.Kusto                            Core,Desk {Add-AzKustoClusterLanguageExtension, Add-AzKustoDatabasePrincipal, Get-AzK…
Script     1.5.0                 Az.LogicApp                         Core,Desk {Get-AzIntegrationAccountAgreement, Get-AzIntegrationAccountAssembly, Get-A…
Script     1.1.3                 Az.MachineLearning                  Core,Desk {Move-AzMlCommitmentAssociation, Get-AzMlCommitmentAssociation, Get-AzMlCom…
Script     1.1.1                 Az.Maintenance                      Core,Desk {Get-AzApplyUpdate, Get-AzConfigurationAssignment, Get-AzMaintenanceConfigu…
Script     2.0.0                 Az.ManagedServices                  Core,Desk {Get-AzManagedServicesAssignment, New-AzManagedServicesAssignment, Remove-A…
Script     1.0.2                 Az.MarketplaceOrdering              Core,Desk {Get-AzMarketplaceTerms, Set-AzMarketplaceTerms}
Script     1.1.1                 Az.Media                            Core,Desk {Sync-AzMediaServiceStorageKey, Set-AzMediaServiceKey, Get-AzMediaServiceKe…
Script     1.1.0                 Az.Migrate                          Core,Desk {Get-AzMigrateDiscoveredServer, Get-AzMigrateJob, Get-AzMigrateProject, Get…
Script     2.7.0                 Az.Monitor                          Core,Desk {Get-AzMetricDefinition, Get-AzMetric, Remove-AzLogProfile, Get-AzLogProfil…
Script     4.10.0                Az.Network                          Core,Desk {Add-AzApplicationGatewayAuthenticationCertificate, Get-AzApplicationGatewa…
Script     1.1.1                 Az.NotificationHubs                 Core,Desk {Get-AzNotificationHub, Get-AzNotificationHubAuthorizationRule, Get-AzNotif…
Script     2.3.0                 Az.OperationalInsights              Core,Desk {New-AzOperationalInsightsAzureActivityLogDataSource, New-AzOperationalInsi…
Script     1.4.1                 Az.PolicyInsights                   Core,Desk {Get-AzPolicyEvent, Get-AzPolicyState, Get-AzPolicyStateSummary, Get-AzPoli…
Script     1.1.2                 Az.PowerBIEmbedded                  Core,Desk {Remove-AzPowerBIWorkspaceCollection, Get-AzPowerBIWorkspaceCollection, Get…
Script     1.0.3                 Az.PrivateDns                       Core,Desk {Get-AzPrivateDnsZone, Remove-AzPrivateDnsZone, Set-AzPrivateDnsZone, New-A…
Script     4.4.0                 Az.RecoveryServices                 Core,Desk {Get-AzRecoveryServicesBackupProperty, Get-AzRecoveryServicesVault, Get-AzR…
Script     1.5.0                 Az.RedisCache                       Core,Desk {Remove-AzRedisCachePatchSchedule, New-AzRedisCacheScheduleEntry, Get-AzRed…
Script     1.0.0                 Az.RedisEnterpriseCache             Core,Desk {Export-AzRedisEnterpriseCache, Get-AzRedisEnterpriseCache, Get-AzRedisEnte…
Script     1.0.3                 Az.Relay                            Core,Desk {New-AzRelayNamespace, Get-AzRelayNamespace, Set-AzRelayNamespace, Remove-A…
Script     1.0.0                 Az.ResourceMover                    Core,Desk {Add-AzResourceMoverMoveResource, Get-AzResourceMoverMoveCollection, Get-Az…
Script     4.3.0                 Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRoleAssignment, Ne…
Script     1.0.0                 Az.Security                         Core,Desk {Get-AzSecurityAlert, Set-AzSecurityAlert, Get-AzSecurityAutoProvisioningSe…
Script     1.0.0                 Az.SecurityInsights                 Core,Desk {Get-AzSentinelAlertRuleAction, New-AzSentinelAlertRuleAction, Remove-AzSen…
Script     1.5.0                 Az.ServiceBus                       Core,Desk {New-AzServiceBusNamespace, Get-AzServiceBusNamespace, Set-AzServiceBusName…
Script     3.0.1                 Az.ServiceFabric                    Core,Desk {Add-AzServiceFabricClientCertificate, Add-AzServiceFabricNode, Add-AzServi…
Script     1.3.0                 Az.SignalR                          Core,Desk {New-AzSignalR, Get-AzSignalR, Get-AzSignalRKey, New-AzSignalRKey…}
Script     3.4.1                 Az.Sql                              Core,Desk {Get-AzSqlDatabaseTransparentDataEncryption, Get-AzSqlDatabaseTransparentDa…
Script     1.1.0                 Az.SqlVirtualMachine                Core,Desk {New-AzSqlVM, Get-AzSqlVM, Update-AzSqlVM, Remove-AzSqlVM…}
Script     3.10.0                Az.Storage                          Core,Desk {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStorageAccount, New-A…
Script     1.5.0                 Az.StorageSync                      Core,Desk {Invoke-AzStorageSyncCompatibilityCheck, New-AzStorageSyncService, Get-AzSt…
Script     2.0.0                 Az.StreamAnalytics                  Core,Desk {Get-AzStreamAnalyticsCluster, Get-AzStreamAnalyticsClusterStreamingJob, Ge…
Script     1.0.0                 Az.Support                          Core,Desk {Get-AzSupportService, Get-AzSupportProblemClassification, Get-AzSupportTic…
Script     1.0.4                 Az.TrafficManager                   Core,Desk {Add-AzTrafficManagerCustomHeaderToEndpoint, Remove-AzTrafficManagerCustomH…
Script     2.8.1                 Az.Websites                         Core,Desk {Get-AzAppServicePlan, Set-AzAppServicePlan, New-AzAppServicePlan, Remove-A…

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

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   7.0.0.0               CimCmdlets                          Core      {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSession…}
Manifest   1.2.5                 Microsoft.PowerShell.Archive        Desk      {Compress-Archive, Expand-Archive}
Manifest   7.0.0.0               Microsoft.PowerShell.Diagnostics    Core      {Get-WinEvent, New-WinEvent, Get-Counter}
Manifest   7.0.0.0               Microsoft.PowerShell.Host           Core      {Start-Transcript, Stop-Transcript}
Manifest   7.0.0.0               Microsoft.PowerShell.Management     Core      {Add-Content, Clear-Content, Get-Clipboard, Set-Clipboard…}
Manifest   7.0.0.0               Microsoft.PowerShell.Security       Core      {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential…}
Manifest   7.0.0.0               Microsoft.PowerShell.Utility        Core      {Export-Alias, Get-Alias, Import-Alias, New-Alias…}
Manifest   7.0.0.0               Microsoft.WSMan.Management          Core      {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSSP, Set-WSManQuic…
Script     1.4.7                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource…}
Script     2.2.5                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability…}
Script     2.0.5                 PSDesiredStateConfiguration         Core      {Configuration, New-DscChecksum, Get-DscResource, Invoke-DscResource}
Script     7.0.0.0               PSDiagnostics                       Core      {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSManTrace, Enable-…
Script     2.1.0                 PSReadLine                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Remove-PSReadLineKeyHa…
Binary     2.0.3                 ThreadJob                           Desk      Start-ThreadJob

    Directory: C:\Users\REDACTED\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\PowerShell

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.0.1.10              GoogleCloud                         Desk      {Add-GcsBucketAcl, Get-GcsBucketAcl, Remove-GcsBucketAcl, Add-GcsObjectAcl…}
Script     1.0.1.10              GoogleCloudBeta                     Desk      {Get-BqDataset, Set-BqDataset, New-BqDataset, Remove-BqDataset…}

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     5.1.2                 Azure                               Desk      {Get-AzureAutomationCertificate, Get-AzureAutomationConnection, New-AzureAu…
Manifest   0.5.0                 Azure.AnalysisServices              Desk      {Add-AzureAnalysisServicesAccount, Restart-AzureAnalysisServicesInstance, E…
Script     4.2.1                 Azure.Storage                       Desk      {Get-AzureStorageTable, New-AzureStorageTableSASToken, New-AzureStorageTabl…
Script     5.7.0                 AzureRM                             Desk
Script     0.6.6                 AzureRM.AnalysisServices            Desk      {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnalysisServicesServe…
Script     5.1.2                 AzureRM.ApiManagement               Desk      {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSsoToken, New-Azur…
Script     0.1.3                 AzureRM.ApplicationInsights         Desk      {Get-AzureRmApplicationInsights, New-AzureRmApplicationInsights, Remove-Azu…
Script     4.3.2                 AzureRM.Automation                  Desk      {Get-AzureRMAutomationHybridWorkerGroup, Get-AzureRmAutomationJobOutputReco…
Script     4.0.4                 AzureRM.Backup                      Desk      {Backup-AzureRmBackupItem, Enable-AzureRmBackupContainerReregistration, Get…
Script     4.0.6                 AzureRM.Batch                       Desk      {Remove-AzureRmBatchAccount, Get-AzureRmBatchAccount, Get-AzureRmBatchAccou…
Script     0.14.1                AzureRM.Billing                     Desk      {Get-AzureRmBillingInvoice, Get-AzureRmBillingPeriod, Get-AzureRmEnrollment…
Script     4.2.2                 AzureRM.Cdn                         Desk      {Get-AzureRmCdnProfile, Get-AzureRmCdnProfileSsoUrl, New-AzureRmCdnProfile,…
Script     0.9.4                 AzureRM.CognitiveServices           Desk      {Get-AzureRmCognitiveServicesAccount, Get-AzureRmCognitiveServicesAccountKe…
Script     4.6.0                 AzureRM.Compute                     Desk      {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet, New-AzureRmAvai…
Script     0.3.1                 AzureRM.Consumption                 Desk      Get-AzureRmConsumptionUsageDetail
Script     0.2.5                 AzureRM.ContainerInstance           Desk      {New-AzureRmContainerGroup, Get-AzureRmContainerGroup, Remove-AzureRmContai…
Script     1.0.4                 AzureRM.ContainerRegistry           Desk      {New-AzureRmContainerRegistry, Get-AzureRmContainerRegistry, Update-AzureRm…
Script     4.2.2                 AzureRM.DataFactories               Desk      {Remove-AzureRmDataFactory, Get-AzureRmDataFactoryRun, Get-AzureRmDataFacto…
Script     0.5.3                 AzureRM.DataFactoryV2               Desk      {Set-AzureRmDataFactoryV2, Update-AzureRmDataFactoryV2, Get-AzureRmDataFact…
Script     4.2.3                 AzureRM.DataLakeAnalytics           Desk      {Get-AzureRmDataLakeAnalyticsDataSource, New-AzureRmDataLakeAnalyticsCatalo…
Script     5.2.0                 AzureRM.DataLakeStore               Desk      {Get-AzureRmDataLakeStoreTrustedIdProvider, Remove-AzureRmDataLakeStoreTrus…
Script     4.0.4                 AzureRM.DevTestLabs                 Desk      {Get-AzureRmDtlAllowedVMSizesPolicy, Get-AzureRmDtlAutoShutdownPolicy, Get-…
Script     4.1.2                 AzureRM.Dns                         Desk      {Get-AzureRmDnsRecordSet, New-AzureRmDnsRecordConfig, Remove-AzureRmDnsReco…
Script     0.3.2                 AzureRM.EventGrid                   Desk      {New-AzureRmEventGridTopic, Get-AzureRmEventGridTopic, Set-AzureRmEventGrid…
Script     0.6.3                 AzureRM.EventHub                    Desk      {New-AzureRmEventHubNamespace, Get-AzureRmEventHubNamespace, Set-AzureRmEve…
Script     4.1.2                 AzureRM.HDInsight                   Desk      {Get-AzureRmHDInsightJob, New-AzureRmHDInsightSqoopJobDefinition, Wait-Azur…
Script     4.0.4                 AzureRM.Insights                    Desk      {Get-AzureRmMetricDefinition, Get-AzureRmMetric, Remove-AzureRmLogProfile, …
Script     3.1.2                 AzureRM.IotHub                      Desk      {Add-AzureRmIotHubKey, Get-AzureRmIotHubEventHubConsumerGroup, Get-AzureRmI…
Script     4.3.0                 AzureRM.KeyVault                    Desk      {Add-AzureKeyVaultCertificate, Set-AzureKeyVaultCertificateAttribute, Stop-…
Script     4.0.3                 AzureRM.LogicApp                    Desk      {Get-AzureRmIntegrationAccountAgreement, Get-AzureRmIntegrationAccountCallb…
Script     0.17.2                AzureRM.MachineLearning             Desk      {Move-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommitmentAssociation, G…
Script     0.4.2                 AzureRM.MachineLearningCompute      Desk      {Get-AzureRmMlOpCluster, Get-AzureRmMlOpClusterKey, Test-AzureRmMlOpCluster…
Script     0.2.1                 AzureRM.MarketplaceOrdering         Desk      {Get-AzureRmMarketplaceTerms, Set-AzureRmMarketplaceTerms}
Script     0.9.2                 AzureRM.Media                       Desk      {Sync-AzureRmMediaServiceStorageKeys, Set-AzureRmMediaServiceKey, Get-Azure…
Script     5.4.2                 AzureRM.Network                     Desk      {Add-AzureRmApplicationGatewayAuthenticationCertificate, Get-AzureRmApplica…
Script     4.1.1                 AzureRM.NotificationHubs            Desk      {Get-AzureRmNotificationHub, Get-AzureRmNotificationHubAuthorizationRules, …
Script     4.3.2                 AzureRM.OperationalInsights         Desk      {New-AzureRmOperationalInsightsAzureActivityLogDataSource, New-AzureRmOpera…
Script     4.1.4                 AzureRM.PowerBIEmbedded             Desk      {Remove-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPowerBIWorkspaceColle…
Script     4.6.0                 AzureRM.Profile                     Desk      {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave, Enable-Azur…
Script     4.1.2                 AzureRM.RecoveryServices            Desk      {Get-AzureRmRecoveryServicesBackupProperty, Get-AzureRmRecoveryServicesVaul…
Script     4.1.2                 AzureRM.RecoveryServices.Backup     Desk      {Backup-AzureRmRecoveryServicesBackupItem, Get-AzureRmRecoveryServicesBacku…
Script     0.2.4                 AzureRM.RecoveryServices.SiteRecov… Desk      {Edit-AzureRmRecoveryServicesAsrRecoveryPlan, Get-AzureRmRecoveryServicesAs…
Script     4.1.2                 AzureRM.RedisCache                  Desk      {Remove-AzureRmRedisCachePatchSchedule, New-AzureRmRedisCacheScheduleEntry,…
Script     0.3.3                 AzureRM.Relay                       Desk      {New-AzureRmRelayNamespace, Get-AzureRmRelayNamespace, Set-AzureRmRelayName…
Script     5.5.2                 AzureRM.Resources                   Desk      {Get-AzureRmProviderOperation, Remove-AzureRmRoleAssignment, Get-AzureRmRol…
Script     0.16.3                AzureRM.Scheduler                   Desk      {Disable-AzureRmSchedulerJobCollection, Enable-AzureRmSchedulerJobCollectio…
Script     4.1.2                 AzureRM.ServerManagement            Desk      {Invoke-AzureRmServerManagementPowerShellCommand, Get-AzureRmServerManageme…
Script     0.6.4                 AzureRM.ServiceBus                  Desk      {New-AzureRmServiceBusNamespace, Get-AzureRmServiceBusNamespace, Set-AzureR…
Script     0.3.4                 AzureRM.ServiceFabric               Desk      {Add-AzureRmServiceFabricApplicationCertificate, Add-AzureRmServiceFabricCl…
Script     5.0.6                 AzureRM.SiteRecovery                Desk      {Get-AzureRmSiteRecoveryFabric, New-AzureRmSiteRecoveryFabric, Remove-Azure…
Script     4.4.0                 AzureRM.Sql                         Desk      {Get-AzureRmSqlDatabaseTransparentDataEncryption, Get-AzureRmSqlDatabaseTra…
Script     4.2.3                 AzureRM.Storage                     Desk      {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, New-AzureRmStorag…
Script     4.0.4                 AzureRM.StreamAnalytics             Desk      {Get-AzureRmStreamAnalyticsFunction, Get-AzureRmStreamAnalyticsDefaultFunct…
Script     4.0.1                 AzureRM.Tags                        Desk      {Remove-AzureRmTag, Get-AzureRmTag, New-AzureRmTag}
Script     4.0.3                 AzureRM.TrafficManager              Desk      {Disable-AzureRmTrafficManagerEndpoint, Enable-AzureRmTrafficManagerEndpoin…
Script     4.0.2                 AzureRM.UsageAggregates             Desk      Get-UsageAggregates
Script     4.2.2                 AzureRM.Websites                    Desk      {Get-AzureRmAppServicePlan, Set-AzureRmAppServicePlan, New-AzureRmAppServic…
Script     1.0.1                 Microsoft.PowerShell.Operation.Val… Desk      {Get-OperationValidation, Invoke-OperationValidation}
Binary     1.0.0.1               PackageManagement                   Desk      {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource…}
Script     3.4.0                 Pester                              Desk      {Describe, Context, It, Should…}
Script     1.0.0.1               PowerShellGet                       Desk      {Install-Module, Find-Module, Save-Module, Update-Module…}
Script     2.0.0      beta2      PSReadline                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Remove-PSReadLineKeyHa…

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

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   1.0.0.0               AppBackgroundTask                   Core,Desk {Disable-AppBackgroundTaskDiagnosticLog, Enable-AppBackgroundTaskDiagnostic…
Manifest   2.0.1.0               Appx                                Core,Desk {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest, Remove-AppxPack…
Script     1.0.0.0               AssignedAccess                      Core,Desk {Clear-AssignedAccess, Get-AssignedAccess, Set-AssignedAccess}
Manifest   1.0.0.0               BitLocker                           Core,Desk {Unlock-BitLocker, Suspend-BitLocker, Resume-BitLocker, Remove-BitLockerKey…
Manifest   2.0.0.0               BitsTransfer                        Core,Desk {Add-BitsFile, Complete-BitsTransfer, Get-BitsTransfer, Remove-BitsTransfer…
Manifest   1.0.0.0               BranchCache                         Core,Desk {Add-BCDataCacheExtension, Clear-BCCache, Disable-BC, Disable-BCDowngrading…
Manifest   1.0                   Defender                            Core,Desk {Get-MpPreference, Set-MpPreference, Add-MpPreference, Remove-MpPreference…}
Manifest   1.0.2.0               DeliveryOptimization                Core,Desk {Delete-DeliveryOptimizationCache, Set-DeliveryOptimizationStatus, Get-Deli…
Manifest   1.0.0.0               DirectAccessClientComponents        Core,Desk {Disable-DAManualEntryPointSelection, Enable-DAManualEntryPointSelection, G…
Script     3.0                   Dism                                Core,Desk {Add-AppxProvisionedPackage, Add-WindowsDriver, Add-WindowsCapability, Add-…
Manifest   1.0.0.0               DnsClient                           Core,Desk {Resolve-DnsName, Clear-DnsClientCache, Get-DnsClient, Get-DnsClientCache…}
Manifest   1.0.0.0               EventTracingManagement              Core,Desk {Start-EtwTraceSession, New-EtwTraceSession, Get-EtwTraceSession, Update-Et…
Manifest   1.0.0.0               HgsClient                           Core,Desk {Get-HgsAttestationBaselinePolicy, Get-HgsClientConfiguration, Test-HgsClie…
Manifest   1.0.0.0               HgsDiagnostics                      Core,Desk {New-HgsTraceTarget, Get-HgsTrace, Get-HgsTraceFileData, Test-HgsTraceTarge…
Binary     2.0.0.0               Hyper-V                             Core,Desk {Add-VMAssignableDevice, Add-VMDvdDrive, Add-VMFibreChannelHba, Add-VMGpuPa…
Binary     1.1                   Hyper-V                             Core,Desk {Add-VMDvdDrive, Add-VMFibreChannelHba, Add-VMHardDiskDrive, Add-VMMigratio…
Script     1.1.0.0               IISAdministration                   Core,Desk
Manifest   2.0.0.0               International                       Core,Desk {Get-WinDefaultInputMethodOverride, Set-WinDefaultInputMethodOverride, Get-…
Manifest   1.0.0.0               Kds                                 Core,Desk {Add-KdsRootKey, Get-KdsRootKey, Test-KdsRootKey, Set-KdsConfiguration…}
Manifest   3.0.0.0               Microsoft.PowerShell.Diagnostics    Core,Desk {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter…}
Manifest   1.0.0.0               Microsoft.PowerShell.LocalAccounts  Core,Desk {Add-LocalGroupMember, Disable-LocalUser, Enable-LocalUser, Get-LocalGroup…}
Manifest   3.1.0.0               Microsoft.PowerShell.Management     Core,Desk {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path…}
Manifest   1.0                   MMAgent                             Core,Desk {Disable-MMAgent, Enable-MMAgent, Set-MMAgent, Get-MMAgent…}
Manifest   2.0.0.0               NetAdapter                          Core,Desk {Disable-NetAdapter, Disable-NetAdapterBinding, Disable-NetAdapterChecksumO…
Manifest   1.0.0.0               NetConnection                       Core,Desk {Get-NetConnectionProfile, Set-NetConnectionProfile}
Manifest   1.0.0.0               NetEventPacketCapture               Core,Desk {New-NetEventSession, Remove-NetEventSession, Get-NetEventSession, Set-NetE…
Manifest   2.0.0.0               NetLbfo                             Core,Desk {Add-NetLbfoTeamMember, Add-NetLbfoTeamNic, Get-NetLbfoTeam, Get-NetLbfoTea…
Manifest   1.0.0.0               NetNat                              Core,Desk {Get-NetNat, Get-NetNatExternalAddress, Get-NetNatStaticMapping, Get-NetNat…
Manifest   2.0.0.0               NetQos                              Core,Desk {Get-NetQosPolicy, Set-NetQosPolicy, Remove-NetQosPolicy, New-NetQosPolicy}
Manifest   2.0.0.0               NetSecurity                         Core,Desk {Get-DAPolicyChange, New-NetIPsecAuthProposal, New-NetIPsecMainModeCryptoPr…
Manifest   1.0.0.0               NetSwitchTeam                       Core,Desk {New-NetSwitchTeam, Remove-NetSwitchTeam, Get-NetSwitchTeam, Rename-NetSwit…
Manifest   1.0.0.0               NetTCPIP                            Core,Desk {Get-NetIPAddress, Get-NetIPInterface, Get-NetIPv4Protocol, Get-NetIPv6Prot…
Manifest   1.0.0.0               NetworkConnectivityStatus           Core,Desk {Get-DAConnectionStatus, Get-NCSIPolicyConfiguration, Reset-NCSIPolicyConfi…
Manifest   1.0.0.0               NetworkSwitchManager                Core,Desk {Disable-NetworkSwitchEthernetPort, Enable-NetworkSwitchEthernetPort, Get-N…
Manifest   1.0.0.0               NetworkTransition                   Core,Desk {Add-NetIPHttpsCertBinding, Disable-NetDnsTransitionConfiguration, Disable-…
Manifest   1.0.0.0               PcsvDevice                          Core,Desk {Get-PcsvDevice, Start-PcsvDevice, Stop-PcsvDevice, Restart-PcsvDevice…}
Manifest   1.0.0.0               PKI                                 Core,Desk {Add-CertificateEnrollmentPolicyServer, Export-Certificate, Export-PfxCerti…
Manifest   1.0.0.0               PnpDevice                           Core,Desk {Get-PnpDevice, Get-PnpDeviceProperty, Enable-PnpDevice, Disable-PnpDevice}
Manifest   1.1                   PrintManagement                     Core,Desk {Add-Printer, Add-PrinterDriver, Add-PrinterPort, Get-PrintConfiguration…}
Binary     1.0.12                ProcessMitigations                  Core,Desk {Get-ProcessMitigation, Set-ProcessMitigation, ConvertTo-ProcessMitigationP…
Script     3.0                   Provisioning                        Core,Desk {Install-ProvisioningPackage, Export-ProvisioningPackage, Install-TrustedPr…
Manifest   1.0.0.0               ScheduledTasks                      Core,Desk {Get-ScheduledTask, Set-ScheduledTask, Register-ScheduledTask, Unregister-S…
Manifest   2.0.0.0               SecureBoot                          Core,Desk {Confirm-SecureBootUEFI, Set-SecureBootUEFI, Get-SecureBootUEFI, Format-Sec…
Manifest   2.0.0.0               SmbShare                            Core,Desk {Get-SmbShare, Remove-SmbShare, Set-SmbShare, Block-SmbShareAccess…}
Manifest   2.0.0.0               SmbWitness                          Core,Desk {Get-SmbWitnessClient, Move-SmbWitnessClient, gsmbw, msmbw…}
Manifest   1.0.0.1               StartLayout                         Core,Desk {Export-StartLayout, Import-StartLayout, Export-StartLayoutEdgeAssets, Get-…
Manifest   2.0.0.0               Storage                             Core,Desk {Add-InitiatorIdToMaskingSet, Add-PartitionAccessPath, Add-PhysicalDisk, Ad…
Manifest   2.0.0.0               TLS                                 Core,Desk {New-TlsSessionTicketKey, Enable-TlsSessionTicketKey, Disable-TlsSessionTic…
Manifest   1.0.0.0               TroubleshootingPack                 Core,Desk {Get-TroubleshootingPack, Invoke-TroubleshootingPack}
Manifest   2.0.0.0               TrustedPlatformModule               Core,Desk {Get-Tpm, Initialize-Tpm, Clear-Tpm, Unblock-Tpm…}
Binary     2.1.639.0             UEV                                 Core,Desk
Manifest   2.0.0.0               VpnClient                           Core,Desk {Add-VpnConnection, Set-VpnConnection, Remove-VpnConnection, Get-VpnConnect…
Manifest   1.0.0.0               Wdac                                Core,Desk {Get-OdbcDriver, Set-OdbcDriver, Get-OdbcDsn, Add-OdbcDsn…}
Manifest   2.0.0.0               Whea                                Core,Desk {Get-WheaMemoryPolicy, Set-WheaMemoryPolicy}
Manifest   1.0.0.0               WindowsDeveloperLicense             Core,Desk {Get-WindowsDeveloperLicense, Unregister-WindowsDeveloperLicense, Show-Wind…
Script     1.0                   WindowsErrorReporting               Core,Desk {Enable-WindowsErrorReporting, Disable-WindowsErrorReporting, Get-WindowsEr…
Manifest   1.0.0.0               WindowsSearch                       Core,Desk {Get-WindowsSearchSetting, Set-WindowsSearchSetting}
Manifest   1.0.0.0               WindowsUpdate                       Core,Desk Get-WindowsUpdateLog
Manifest   1.0.0.2               WindowsUpdateProvider               Core,Desk {Get-WUAVersion, Get-WULastInstallationDate, Get-WULastScanSuccessDate, Get…

    Directory: C:\Program Files (x86)\Microsoft SQL Server\150\Tools\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   15.0                  SQLPS                               Desk

Debug output

Console Output (also creates file almost_all_output.log)

PS > .\Deploy.ps1 -resourceGroupName "Redacted_resource_group" -storageAccountName "redactedstoragename" -blobContainerName "redacted-blob-name" -someFilePath "./somefile.txt" *> almost_all_output.log

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"):
PS >

Contents of almost_all_output.log almost_all_output.log.txt

7:39:05 PM - GetAzureStorageAccountCommand begin processing with ParameterSet 'AccountNameParameterSet'.
7:39:05 PM - using account id 'redacted@redacted.com'...
[Common.Authentication]: Authenticating using Account: 'redacted@redacted.com', environment: 'AzureCloud', tenant: 'redacted-uuid-1'
7:39:05 PM - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'redacted-uuid-1', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'redacted@redacted.com'
SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: 
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05] Found 1 cache accounts and 0 broker accounts
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05] Returning 1 accounts
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] MSAL MSAL.NetCore with assembly version '4.30.1.0'. CorrelationId(949ec45d-c8f3-467e-8408-7c23ed61d05d)
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] === AcquireTokenSilent Parameters ===
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] LoginHint provided: False
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Account provided: True
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] ForceRefresh: False
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] 
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) - 
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 949ec45d-c8f3-467e-8408-7c23ed61d05d

(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] === Token Acquisition (SilentRequest) started:

    Authority Host: login.microsoftonline.com
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Access token has expired or about to expire. [Current time (09/07/2021 23:39:05) - Expiration Time (09/07/2021 23:24:29 +00:00) - Extended Expiration Time (09/07/2021 23:24:29 +00:00)]
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Refresh token found in the cache? - True
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Resolving authority endpoints... Already resolved? - TRUE
Request [d3efd1b0-1470-4997-952a-0e0933af0f8f] POST https://login.microsoftonline.com/redacted-uuid-1/oauth2/v2.0/token
x-client-SKU:REDACTED
x-client-Ver:REDACTED
x-client-CPU:REDACTED
x-client-OS:REDACTED
x-client-current-telemetry:REDACTED
x-client-last-telemetry:REDACTED
x-ms-lib-capability:REDACTED
client-request-id:REDACTED
return-client-request-id:REDACTED
x-app-name:REDACTED
x-app-ver:REDACTED
x-ms-client-request-id:d3efd1b0-1470-4997-952a-0e0933af0f8f
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Identity/1.4.0,(.NET 5.0.9; Microsoft Windows 10.0.19042)
Content-Type:application/x-www-form-urlencoded
client assembly: Azure.Identity
Response [d3efd1b0-1470-4997-952a-0e0933af0f8f] 200 OK (00.5s)
Cache-Control:no-store, no-cache
Pragma:no-cache
Strict-Transport-Security:REDACTED
X-Content-Type-Options:REDACTED
P3P:REDACTED
client-request-id:REDACTED
x-ms-request-id:5279a492-5467-4b2e-bf2d-5a019f2d3001
x-ms-ests-server:REDACTED
x-ms-clitelem:REDACTED
Set-Cookie:REDACTED
Date:Tue, 07 Sep 2021 23:39:04 GMT
Content-Type:application/json; charset=utf-8
Expires:-1
Content-Length:5752

(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Checking client info returned from the server..
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Saving Token Response to cache..
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Subject not present in Id token
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Azure region was not configured or could not be discovered. Not using a regional authority.
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Saving AT in cache and removing overlapping ATs...
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Looking for scopes for the authority in the cache which intersect with https://management.core.windows.net//.default
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Intersecting scope entries count - 1
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Matching entries after filtering by user - 1
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Saving Id Token and Account in cache ...
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Saving RT in cache...
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05] Not writing FRT in ADAL legacy cache. 
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] Fetched access token from host login.microsoftonline.com. 
(False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.19042 [09/07/2021 23:39:05 - ] === Token Acquisition finished successfully. An access token was returned with Expiration Time: 09/08/2021 00:39:04 +00:00 and Scopes https://management.core.windows.net//user_impersonation https://management.core.windows.net//.default
SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:  ExpiresOn: 2021-09-08T00:39:04.0000000+00:00
[Common.Authentication]: Received token with LoginType 'User', Tenant: 'redacted-uuid-1', UserId: 'redacted@redacted.com'
============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/redacted-uuid-2/resourceGroups/Redacted_resource_group/providers/Microsoft.Storage/storageAccounts/redactedstoragename?api-version=2021-04-01

Headers:
x-ms-client-request-id        : bfbaf572-2259-4097-9b79-4f5eb4cb19d3
Accept-Language               : en-US

Body:

============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
x-ms-request-id               : 4f79f009-5266-405c-a6b4-d06b02451ec4
Strict-Transport-Security     : max-age=31536000; includeSubDomains
Server                        : Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
x-ms-ratelimit-remaining-subscription-reads: 11999
x-ms-correlation-request-id   : 5b9f9c24-13f2-43ea-b539-cefa650d5fbb
x-ms-routing-request-id       : EASTUS2:20210907T233905Z:5b9f9c24-13f2-43ea-b539-cefa650d5fbb
X-Content-Type-Options        : nosniff
Date                          : Tue, 07 Sep 2021 23:39:05 GMT

Body:
{
  "sku": {
    "name": "Standard_LRS",
    "tier": "Standard"
  },
  "kind": "StorageV2",
  "id": "/subscriptions/redacted-uuid-2/resourceGroups/Redacted_resource_group/providers/Microsoft.Storage/storageAccounts/redactedstoragename",
  "name": "redactedstoragename",
  "type": "Microsoft.Storage/storageAccounts",
  "location": "centralus",
  "tags": {
    "ApplicationName": "Nginx"
  },
  "properties": {
    "keyCreationTime": {
      "key1": "2021-08-21T17:17:04.5200994Z",
      "key2": "2021-08-21T17:17:04.5200994Z"
    },
    "privateEndpointConnections": [],
    "minimumTlsVersion": "TLS1_2",
    "allowBlobPublicAccess": false,
    "allowSharedKeyAccess": true,
    "networkAcls": {
      "bypass": "AzureServices",
      "virtualNetworkRules": [],
      "ipRules": [],
      "defaultAction": "Allow"
    },
    "supportsHttpsTrafficOnly": true,
    "encryption": {
      "services": {
        "file": {
          "keyType": "Account",
          "enabled": true,
          "lastEnabledTime": "2021-08-21T17:17:04.5200994Z"
        },
        "blob": {
          "keyType": "Account",
          "enabled": true,
          "lastEnabledTime": "2021-08-21T17:17:04.5200994Z"
        }
      },
      "keySource": "Microsoft.Storage"
    },
    "accessTier": "Hot",
    "provisioningState": "Succeeded",
    "creationTime": "2021-08-21T17:17:04.4107703Z",
    "primaryEndpoints": {
      "dfs": "https://redactedstoragename.dfs.core.windows.net/",
      "web": "https://redactedstoragename.z19.web.core.windows.net/",
      "blob": "https://redactedstoragename.blob.core.windows.net/",
      "queue": "https://redactedstoragename.queue.core.windows.net/",
      "table": "https://redactedstoragename.table.core.windows.net/",
      "file": "https://redactedstoragename.file.core.windows.net/"
    },
    "primaryLocation": "centralus",
    "statusOfPrimary": "available"
  }
}

AzureQoSEvent: Module: Az.Storage:3.10.0; CommandName: Get-AzStorageAccount; PSVersion: 7.1.4; IsSuccess: True; Duration: 00:00:00.8251996
Finish sending metric.
7:39:06 PM - GetAzureStorageAccountCommand end processing.
Next command should NOT prompt but it does when given either -Debug or $DebugPreference='Continue' is set
7:39:06 PM - Init Operation Context for 'SetAzureBlobContentCommand' with client request id  Azure-Storage-PowerShell-689dcd22-b8ba-4916-af70-2ecbdb091ba1. If you want to get more details, please add "-Debug" to your command.
7:39:06 PM - Use storage account 'redactedstoragename' from storage context.

   AccountName: redactedstoragename, ContainerName: redacted-blob-name

Name                 BlobType  Length          ContentType                    LastModified         AccessTier SnapshotTime                 IsDeleted  Versio
                                                                                                                                                      nId
----                 --------  ------          -----------                    ------------         ---------- ------------                 ---------  ------
somefile.txt         BlockBlob 14              application/octet-stream       2021-09-07 23:39:07Z Hot                                     False      
7:39:07 PM - SetAzureBlobContentCommand end processing, Start 53 remote calls. Finish 39 remote calls. Elapsed time 4475248.24 ms. Client operation id: Azure-Storage-PowerShell-689dcd22-b8ba-4916-af70-2ecbdb091ba1.
7:39:07 PM - SetAzureBlobContentCommand end processing.
Transfer Summary
--------------------------------
Total:  1.
Successful: 1.
Failed: 0.

Error output

There was no error so there's nothing to report in this section

blueww commented 3 years ago

@benrobot

If you want to output debug log without user interactive, please don't user -Debug. Please set $DebugPreference = "Continue", and then run the cmdlet. You can see more details in https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.1#debugpreference

benrobot commented 3 years ago

@blueww Thank you. Using $DebugPreference = "Continue" instead of -Debug worked as you said it would. For my needs it appears that using $DebugPreference = "Continue" will be sufficient (actually, better than adding -Debug everywhere).

benrobot commented 3 years ago

With regards to adding -Debug, is the change in behavior intentional?

blueww commented 3 years ago

@benrobot Good to know $DebugPreference = "Continue" is sufficient for your scenario. But I don't quite understand your question "is the change in behavior intentional?" which change and which behavior do you mean?

With -Debug, the cmdlet will always have user interactive. If you just want debug log without user interactive, you can use $DebugPreference = "Continue"

Please review https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.1#debugpreference, see if it can answer your question.

dingmeng-xue commented 3 years ago

@benrobot , below page describes the behavior change with debug parameter. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.1#-debug

benrobot commented 3 years ago

@benrobot , below page describes the behavior change with debug parameter. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.1#-debug

I read the description. The only part that might explain the behavior is

In interactive mode, the Debug parameter overrides the value of the $DebugPreference variable for the current command, setting the value of $DebugPreference to Inquire.

However, there are few problems with this:

  1. The issue still present in non-interactive mode. To run in NonInteractive mode you can use the following command pwsh -NonInteractive .\Deploy.ps1 -resourceGroupName "Redacted_resource_group" -storageAccountName "redactedstoragename" -blobContainerName "redacted-blob-name" -someFilePath "./somefile.txt" *> almost_all_output.log.
  2. It is my understanding that a $DebugPreference of Inquire means the user will be prompted when a debug message is outputted. This is NOT the same as the prompt that was supposed to be suppressed by -Confirm:$False.

The issue being reported

It appears the command Set-AzStorageBlobContent -Debug -Confirm:$False -Force ... attempts to confirm the action (after file upload was completed) with the user even when it is in NonInteractive mode; this results in the error PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.

In addition, adding -Verbose seems to fix the issue: Command Result
pwsh -NonInteractive Set-AzStorageBlobContent -Confirm:$False -Force ... Works as expected; no prompt and no error.
pwsh -NonInteractive Set-AzStorageBlobContent -Confirm:$False -Force -Debug ... Throws PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.
pwsh -NonInteractive Set-AzStorageBlobContent -Confirm:$False -Force -Debug -Verbose ... Works as expected; no prompt and no error.
blueww commented 3 years ago

@benrobot

For run cmdlet in NonInteractive mode, please use $DebugPreference = "Continue", instead of adding -Debug. Do you have any specific reason that must add -debug.

@dingmeng-xue As the questions is mostly on -debug and $DebugPreference behavior, but not for specific cmdlet behaviors, could you please help to answer this?

benrobot commented 3 years ago

@benrobot

For run cmdlet in NonInteractive mode, please use $DebugPreference = "Continue", instead of adding -Debug. Do you have any specific reason that must add -debug.

For my script, using $DebugPreference = "Continue" works. I just want to report a bug regarding the behavior of -Debug. The documentation states that using -Debug in non-interactive mode should set $DebugPreference = "Continue". But it appears that Set-AzStorageBlobContent is not honoring this convention.

From https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.1#-debug:

In non-interactive mode, the Debug parameter overrides the value of the $DebugPreference variable for the current command, setting the value of $DebugPreference to Continue.

I believe this worth fixing or documenting because I regularly use -Debug while writing scripts and I use it with the assumption that it will behave like the documentation states. For example, I recently lost a few hours trying to understand why Set-AzStorageBlobContent was causing my CI/CD pipeline to complain about a prompt in non-interactive mode. I read and re-read the documentation about -Force and -Confirm:$False to make sure I was suppressing the prompts correctly but it didn't help. Then I just started randomly removing parameters to see what would happen. The -Debug parameter was the last one I removed because, one, I wanted to see the output, and two, the -Debug switch was the last parameter I expected to have broken my script.

blueww commented 3 years ago

@benrobot Thanks for the clarify!

The failure when run Set-AzStorageBlobContent -Confirm:$False -Force -Debug in NonInteractive mode, is not from debug log, but from verbose log. So when you add -Verbose it will not prompt to confirm verbose.

The stake track for this is:

System.Management.Automation.PSInvalidOperationException: PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.
   at Microsoft.PowerShell.ConsoleHostUserInterface.HandleThrowOnReadAndPrompt()
   at Microsoft.PowerShell.ConsoleHostUserInterface.PromptForChoice(String caption, String message, Collection`1 choices, Int32 defaultChoice)
   at System.Management.Automation.Internal.Host.InternalHostUserInterface.PromptForChoice(String caption, String message, Collection`1 choices, Int32 defaultChoice)
   at System.Management.Automation.MshCommandRuntime.InquireHelper(String inquireMessage, String inquireCaption, Boolean allowYesToAll, Boolean allowNoToAll, Boolean replaceNoWithHalt, Boolean hasSecurityImpact)
   at System.Management.Automation.MshCommandRuntime.WriteVerbose(VerboseRecord record, Boolean overrideInquire)
   at System.Management.Automation.Cmdlet.WriteVerbose(String text)
   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.WriteVerbose(String text)
   at Microsoft.WindowsAzure.Commands.Storage.Common.StorageCloudCmdletBase`1.WriteTaskSummary()
   at Microsoft.WindowsAzure.Commands.Storage.Blob.StorageDataMovementCmdletBase.DoEndProcessing()
   at Microsoft.WindowsAzure.Commands.Storage.Blob.SetAzureBlobContentCommand.DoEndProcessing()
   at Microsoft.WindowsAzure.Commands.Storage.Blob.SetAzureBlobContentCommand.EndProcessing()
   at System.Management.Automation.CommandProcessorBase.Complete()

@dingmeng-xue Do you have any idea on this?

It looks other cmdlet also has similar behavior, like run Add-AzAccount in NonInteractive mode, will fail with warning message prompt, until add-WarningAction Continue.

As I see, when -Debug is added, debug/warning/verbose/shouldprocess/... will all be output and have prompt, but they will need different parameters to suppress prompt in NonInteractive mode.

However, set $DebugPreference = "Continue" looks can suppress all of them.

dingmeng-xue commented 2 years ago

Cmdlet has attribute [CmdletBinding(SupportsShouldProcess=$true)]. -Force, -WhatIf and -Confirm are added due to SupportsShouldProcess.

Adding -Confirm will show additional prompt Are you sure you want to perform this action? before cmdlet execution. -Confirm:$false or without -confirm will skip that prompt. If cmdlet implements internal prompt logic like current one, another prompt will be shown up. -Force is used to suppress that prompt.

If cmdlet has any prompt, PowerShell in NonInteractive mode shows error Read and Prompt functionality is not available. You need to suppress prompt with -Force and without -Confirm to avoid both prompts which lead above error.

-Debug triggers above 2 prompts as well. The behavior likes -Confirm. -Force can suppress the second prompt but the first prompt is still shown up.

So, $DebugPreference = "Continue" and -Force are recommended combination for executing cmdlet with SupportsShouldProcess attribute in PowerShell non-interactive mode.

benrobot commented 2 years ago

-Debug triggers above 2 prompts as well. The behavior likes -Confirm. -Force can suppress the second prompt but the first prompt is still shown up.

@dingmeng-xue Is this behavior documented somewhere? If not, maybe we can add this information to https://docs.microsoft.com/en-us/powershell/azure/troubleshooting?view=azps-6.4.0 or some other more global location.

I ask because the page https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.1#-debug states

In non-interactive mode, the Debug parameter overrides the value of the $DebugPreference variable for the current command, setting the value of $DebugPreference to Continue.

which appears to be different from your statement.

dingmeng-xue commented 2 years ago

HI @benrobot,

I believe there is no official doc because the behavior depends cmdlet implementation. You can try below example code. It's a typical logic and simplified code of Azure PowerShell cmdlet. You need to name it as foo.psm1 and then import it as module.

function Test-MyCode {
    [CmdletBinding(SupportsShouldProcess=$true)]
    param(
        # This switch allows the user to override the prompt for confirmation
        [switch]$Force
    )

    if ($PSCmdlet.ShouldProcess('Target')) {
        if ($Force -or $PSCmdlet.ShouldContinue('Do you want to continue?', 'Caption')) {
            Write-Host "Do action"
        }
    }
    Write-Debug "This is debug message"
    Write-Verbose "This is verbose message"
    Write-Host "Test"
}

But we cannot confirm the implementation of all cmdlets of Azure PowerShell following the same approach. It's not easy to track kinds of this issue. So, we only suggest user to use $DebugPreference = "Continue" instead of appending -Debug.

I agree with you that -Debug seems do more than $DebugPreference = "Continue". It's a general question to PowerShell. It should be discussed in its repo https://github.com/PowerShell/PowerShell/issues.