Set-AzStorageBlobContent : Failed to open file C:\Users\Client\Temp\Sample.csv: Illegal characters in path..
Set-AzStorageBlobContent : Failed to open file C:\Users\Client\Temp\Sample.csv: Illegal characters in path..
Unable to use Set-AzStorageBlobContent to upload file to Azure Blob Storage, complaining: Illegal characters in path..
This issue is reproduced in Automation Account, where both AzureRM and Az modules are installed. (I have not figured out how to remove AzureRM modules from Automation accounts, there were several modules marked as global and cannot be removed)
The issue cannot be reproduced on my Windows 7 machine, which have the same Az.Storage and Az.Account version.
Remove-Module AzureRm*
Import-Module Az.Accounts -MinimumVersion 1.2.1 -Verbose:$false
Import-Module Az.Storage -MinimumVersion 1.0.2 -Verbose:$false
#Requires -Modules @{ ModuleName="Az.Storage"; RequiredVersion="1.0.2" }, @{ ModuleName="Az.Accounts"; RequiredVersion="1.0.2" }
$connectionName = "AzureRunAsConnection"
try {
# Get the connection "AzureRunAsConnection "
$servicePrincipalConnection = Get-AutomationConnection -Name $connectionName
Connect-AzAccount `
-ServicePrincipal `
-Tenant $servicePrincipalConnection.TenantId `
-ApplicationId $servicePrincipalConnection.ApplicationId `
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint | Out-Null
} catch {
if (!$servicePrincipalConnection) {
$ErrorMessage = "Connection $connectionName not found."
throw $ErrorMessage
} else {
Write-Error -Message $_.Exception
throw $_.Exception
}
}
$DebugPreference = "Continue"
Set-AzContext "subscription"
$csvContainer = "inventory"
$csvSA = "azuresa"
$csvSARG = "sa_rg"
$csvFileName = "Sample.csv"
$TempCsv = $env:TEMP + "\" + $csvFileName
Get-Process | Export-Csv $TempCsv -NoTypeInformation -Force -Confirm:$false
$StorageAccount = Get-AzStorageAccount -ResourceGroupName $csvSARG -Name $csvSA
Set-AzStorageBlobContent -Container $csvContainer -File $TempCsv -Force -Confirm:$false -Context $StorageAccount.Context -Debug
Module Version
Get-Module -ListAvailable
Directory: C:\Modules\User
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.2.1 Az.Accounts {Disable-AzDataCollection, Disable-AzContextAutosave, Enabl...
Script 1.0.0 Az.Aks {Get-AzAks, New-AzAks, Remove-AzAks, Import-AzAksCredential...
Script 1.0.0 Az.AnalysisServices {Resume-AzAnalysisServicesServer, Suspend-AzAnalysisService...
Script 1.0.0 Az.ApiManagement {Add-AzApiManagementRegion, Get-AzApiManagementSsoToken, Ne...
Script 1.0.0 Az.ApplicationInsights {Get-AzApplicationInsights, New-AzApplicationInsights, Remo...
Script 1.0.0 Az.Automation {Get-AzAutomationHybridWorkerGroup, Remove-AzAutomationHybr...
Script 1.0.0 Az.Batch {Remove-AzBatchAccount, Get-AzBatchAccount, Get-AzBatchAcco...
Script 1.0.0 Az.Billing {Get-AzBillingInvoice, Get-AzBillingPeriod, Get-AzEnrollmen...
Script 1.0.0 Az.Cdn {Get-AzCdnProfile, Get-AzCdnProfileSsoUrl, New-AzCdnProfile...
Script 1.0.0 Az.CognitiveServices {Get-AzCognitiveServicesAccount, Get-AzCognitiveServicesAcc...
Script 1.0.0 Az.Compute {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAva...
Script 1.0.0 Az.ContainerInstance {New-AzContainerGroup, Get-AzContainerGroup, Remove-AzConta...
Script 1.0.0 Az.ContainerRegistry {New-AzContainerRegistry, Get-AzContainerRegistry, Update-A...
Script 1.0.0 Az.DataFactory {Set-AzDataFactoryV2, Update-AzDataFactoryV2, Get-AzDataFac...
Script 1.0.0 Az.DataLakeAnalytics {Get-AzDataLakeAnalyticsDataSource, New-AzDataLakeAnalytics...
Script 1.0.0 Az.DataLakeStore {Get-AzDataLakeStoreTrustedIdProvider, Remove-AzDataLakeSto...
Script 1.0.0 Az.DevTestLabs {Get-AzDtlAllowedVMSizesPolicy, Get-AzDtlAutoShutdownPolicy...
Script 1.0.0 Az.Dns {Get-AzDnsRecordSet, New-AzDnsRecordConfig, Remove-AzDnsRec...
Script 1.0.0 Az.EventGrid {New-AzEventGridTopic, Get-AzEventGridTopic, Set-AzEventGri...
Script 1.0.0 Az.EventHub {New-AzEventHubNamespace, Get-AzEventHubNamespace, Set-AzEv...
Script 1.0.0 Az.HDInsight {Get-AzHDInsightJob, New-AzHDInsightSqoopJobDefinition, Wai...
Script 1.0.0 Az.IotHub {Add-AzIotHubKey, Get-AzIotHubEventHubConsumerGroup, Get-Az...
Script 1.0.0 Az.KeyVault {Add-AzKeyVaultCertificate, Update-AzKeyVaultCertificate, S...
Script 1.0.0 Az.LogicApp {Get-AzIntegrationAccountAgreement, Get-AzIntegrationAccoun...
Script 1.0.0 Az.MachineLearning {Move-AzMlCommitmentAssociation, Get-AzMlCommitmentAssociat...
Script 1.0.0 Az.MarketplaceOrdering {Get-AzMarketplaceTerms, Set-AzMarketplaceTerms}
Script 1.0.0 Az.Media {Sync-AzMediaServiceStorageKeys, Set-AzMediaServiceKey, Get...
Script 1.0.0 Az.Monitor {Get-AzMetricDefinition, Get-AzMetric, Remove-AzLogProfile,...
Script 1.0.0 Az.Network {Add-AzApplicationGatewayAuthenticationCertificate, Get-AzA...
Script 1.0.0 Az.NotificationHubs {Get-AzNotificationHub, Get-AzNotificationHubAuthorizationR...
Script 1.0.0 Az.OperationalInsights {New-AzOperationalInsightsAzureActivityLogDataSource, New-A...
Script 1.0.0 Az.PolicyInsights {Get-AzPolicyEvent, Get-AzPolicyState, Get-AzPolicyStateSum...
Script 1.0.0 Az.PowerBIEmbedded {Remove-AzPowerBIWorkspaceCollection, Get-AzPowerBIWorkspac...
Script 1.0.0 Az.RecoveryServices {Get-AzRecoveryServicesBackupProperty, Get-AzRecoveryServic...
Script 1.0.0 Az.RedisCache {Remove-AzRedisCachePatchSchedule, New-AzRedisCacheSchedule...
Script 1.0.0 Az.Relay {New-AzRelayNamespace, Get-AzRelayNamespace, Set-AzRelayNam...
Script 1.0.0 Az.Resources {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRo...
Script 1.0.0 Az.ServiceBus {New-AzServiceBusNamespace, Get-AzServiceBusNamespace, Set-...
Script 1.0.0 Az.ServiceFabric {Add-AzServiceFabricApplicationCertificate, Add-AzServiceFa...
Script 1.0.0 Az.SignalR {New-AzSignalR, Get-AzSignalR, Get-AzSignalRKey, New-AzSign...
Script 1.0.0 Az.Sql {Get-AzSqlDatabaseTransparentDataEncryption, Get-AzSqlDatab...
Script 1.0.2 Az.Storage {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStora...
Script 1.0.0 Az.StreamAnalytics {Get-AzStreamAnalyticsFunction, Get-AzStreamAnalyticsDefaul...
Script 1.0.0 Az.TrafficManager {Add-AzTrafficManagerCustomHeaderToEndpoint, Remove-AzTraff...
Script 1.0.0 Az.Websites {Get-AzAppServicePlan, Set-AzAppServicePlan, New-AzAppServi...
Script 5.3.0 Azure {Get-AzureAutomationCertificate, Get-AzureAutomationConnect...
Script 0.5.4 Azure.AnalysisServices {Add-AzureAnalysisServicesAccount, Restart-AzureAnalysisSer...
Script 4.6.1 Azure.Storage {Get-AzureStorageTable, New-AzureStorageTableSASToken, New-...
Script 6.13.1 AzureRM
Script 0.6.14 AzureRM.AnalysisServices {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnaly...
Script 6.1.7 AzureRM.ApiManagement {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSs...
Script 0.1.8 AzureRM.ApplicationInsights {Get-AzureRmApplicationInsights, New-AzureRmApplicationInsi...
Script 6.1.1 AzureRM.Automation {Get-AzureRMAutomationHybridWorkerGroup, Remove-AzureRmAuto...
Script 4.0.11 AzureRM.Backup {Backup-AzureRmBackupItem, Enable-AzureRmBackupContainerRer...
Script 4.1.5 AzureRM.Batch {Remove-AzureRmBatchAccount, Get-AzureRmBatchAccount, Get-A...
Script 0.14.6 AzureRM.Billing {Get-AzureRmBillingInvoice, Get-AzureRmBillingPeriod, Get-A...
Script 5.0.6 AzureRM.Cdn {Get-AzureRmCdnProfile, Get-AzureRmCdnProfileSsoUrl, New-Az...
Script 0.9.12 AzureRM.CognitiveServices {Get-AzureRmCognitiveServicesAccount, Get-AzureRmCognitiveS...
Script 5.9.1 AzureRM.Compute {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet,...
Script 0.3.7 AzureRM.Consumption {Get-AzureRmConsumptionBudget, Get-AzureRmConsumptionMarket...
Script 0.2.12 AzureRM.ContainerInstance {New-AzureRmContainerGroup, Get-AzureRmContainerGroup, Remo...
Script 1.0.10 AzureRM.ContainerRegistry {New-AzureRmContainerRegistry, Get-AzureRmContainerRegistry...
Script 5.0.3 AzureRM.DataFactories {Remove-AzureRmDataFactory, Get-AzureRmDataFactoryRun, Get-...
Script 0.5.11 AzureRM.DataFactoryV2 {Set-AzureRmDataFactoryV2, Update-AzureRmDataFactoryV2, Get...
Script 5.1.4 AzureRM.DataLakeAnalytics {Get-AzureRmDataLakeAnalyticsDataSource, New-AzureRmDataLak...
Script 6.2.1 AzureRM.DataLakeStore {Get-AzureRmDataLakeStoreTrustedIdProvider, Remove-AzureRmD...
Script 4.0.9 AzureRM.DevTestLabs {Get-AzureRmDtlAllowedVMSizesPolicy, Get-AzureRmDtlAutoShut...
Script 5.1.0 AzureRM.Dns {Get-AzureRmDnsRecordSet, New-AzureRmDnsRecordConfig, Remov...
Script 0.3.7 AzureRM.EventGrid {New-AzureRmEventGridTopic, Get-AzureRmEventGridTopic, Set-...
Script 0.7.0 AzureRM.EventHub {New-AzureRmEventHubNamespace, Get-AzureRmEventHubNamespace...
Script 4.1.8 AzureRM.HDInsight {Get-AzureRmHDInsightJob, New-AzureRmHDInsightSqoopJobDefin...
Script 5.1.5 AzureRM.Insights {Get-AzureRmMetricDefinition, Get-AzureRmMetric, Remove-Azu...
Script 3.1.8 AzureRM.IotHub {Add-AzureRmIotHubKey, Get-AzureRmIotHubEventHubConsumerGro...
Script 5.2.1 AzureRM.KeyVault {Add-AzureKeyVaultCertificate, Update-AzureKeyVaultCertific...
Script 4.1.4 AzureRM.LogicApp {Get-AzureRmIntegrationAccountAgreement, Get-AzureRmIntegra...
Script 0.18.5 AzureRM.MachineLearning {Move-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommitme...
Script 0.4.8 AzureRM.MachineLearningCompute {Get-AzureRmMlOpCluster, Get-AzureRmMlOpClusterKey, Test-Az...
Script 0.2.7 AzureRM.MarketplaceOrdering {Get-AzureRmMarketplaceTerms, Set-AzureRmMarketplaceTerms}
Script 0.10.4 AzureRM.Media {Sync-AzureRmMediaServiceStorageKeys, Set-AzureRmMediaServi...
Script 6.11.1 AzureRM.Network {Add-AzureRmApplicationGatewayAuthenticationCertificate, Ge...
Script 5.0.3 AzureRM.NotificationHubs {Get-AzureRmNotificationHub, Get-AzureRmNotificationHubAuth...
Script 5.0.6 AzureRM.OperationalInsights {New-AzureRmOperationalInsightsAzureActivityLogDataSource, ...
Script 1.1.0 AzureRM.PolicyInsights {Get-AzureRmPolicyEvent, Get-AzureRmPolicyState, Get-AzureR...
Script 4.1.10 AzureRM.PowerBIEmbedded {Remove-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPower...
Script 5.8.2 AzureRM.Profile {Disable-AzureRmDataCollection, Disable-AzureRmContextAutos...
Script 4.1.9 AzureRM.RecoveryServices {Get-AzureRmRecoveryServicesBackupProperty, Get-AzureRmReco...
Script 4.5.2 AzureRM.RecoveryServices.Backup {Backup-AzureRmRecoveryServicesBackupItem, Get-AzureRmRecov...
Script 0.2.12 AzureRM.RecoveryServices.SiteRec... {Edit-AzureRmRecoveryServicesAsrRecoveryPlan, Get-AzureRmRe...
Script 5.1.0 AzureRM.RedisCache {Remove-AzureRmRedisCachePatchSchedule, New-AzureRmRedisCac...
Script 0.3.12 AzureRM.Relay {New-AzureRmRelayNamespace, Get-AzureRmRelayNamespace, Set-...
Script 6.7.3 AzureRM.Resources {Get-AzureRmProviderOperation, Remove-AzureRmRoleAssignment...
Script 0.16.10 AzureRM.Scheduler {Disable-AzureRmSchedulerJobCollection, Enable-AzureRmSched...
Script 0.6.13 AzureRM.ServiceBus {New-AzureRmServiceBusNamespace, Get-AzureRmServiceBusNames...
Script 0.3.15 AzureRM.ServiceFabric {Add-AzureRmServiceFabricApplicationCertificate, Add-AzureR...
Script 1.0.0 AzureRM.SignalR {New-AzureRmSignalR, Get-AzureRmSignalR, Get-AzureRmSignalR...
Script 4.12.1 AzureRM.Sql {Get-AzureRmSqlDatabaseTransparentDataEncryption, Get-Azure...
Script 5.2.0 AzureRM.Storage {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, N...
Script 4.0.10 AzureRM.StreamAnalytics {Get-AzureRmStreamAnalyticsFunction, Get-AzureRmStreamAnaly...
Script 4.0.5 AzureRM.Tags {Remove-AzureRmTag, Get-AzureRmTag, New-AzureRmTag}
Script 4.1.3 AzureRM.TrafficManager {Add-AzureRmTrafficManagerCustomHeaderToEndpoint, Remove-Az...
Script 4.0.5 AzureRM.UsageAggregates Get-UsageAggregates
Script 5.2.0 AzureRM.Websites {Get-AzureRmAppServicePlan, Set-AzureRmAppServicePlan, New-...
Directory: C:\Modules\Global
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.1.0.0 AuditPolicyDsc
Manifest 5.0.0.0 ComputerManagementDsc
Script 0.2 GPRegistryPolicyParser {Parse-PolFile, Read-RegistryPolicies, Create-RegistrySetti...
Script 0.0 Microsoft.PowerShell.Core
Script 0.0 Microsoft.PowerShell.Diagnostics
Script 0.0 Microsoft.PowerShell.Management
Script 0.0 Microsoft.PowerShell.Security
Script 0.0 Microsoft.PowerShell.Utility
Script 0.0 Microsoft.WSMan.Management
Binary 1.0 Orchestrator.AssetManagement.Cmd... {Get-AutomationCertificate, Get-AutomationConnection, Get-S...
Manifest 2.9.0.0 PSDscResources
Manifest 2.1.0.0 SecurityPolicyDsc
Manifest 1.0 StateConfigCompositeResources
Manifest 1.1 xDSCDomainjoin
Manifest 1.1.0.0 xPowerShellExecutionPolicy {Get-TargetResource, Test-TargetResource, Set-TargetResource}
Manifest 1.1.0.0 xRemoteDesktopAdmin
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.1 Microsoft.PowerShell.Operation.V... {Get-OperationValidation, Invoke-OperationValidation}
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packag...
Script 3.4.0 Pester {Describe, Context, It, Should...}
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
Script 1.2 PSReadline {Get-PSReadlineKeyHandler, Set-PSReadlineKeyHandler, Remove...
Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0.0.0 AppBackgroundTask {Disable-AppBackgroundTaskDiagnosticLog, Enable-AppBackgrou...
Manifest 2.0.0.0 Appx {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest,...
Manifest 2.0.0.0 BitsTransfer {Add-BitsFile, Complete-BitsTransfer, Get-BitsTransfer, Rem...
Manifest 1.0.0.0 CimCmdlets {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, ...
Manifest 1.0 Defender {Get-MpPreference, Set-MpPreference, Add-MpPreference, Remo...
Manifest 1.0.0.0 DeliveryOptimization {Get-DeliveryOptimizationStatus, Get-DeliveryOptimizationPe...
Manifest 1.0.0.0 DirectAccessClientComponents {Disable-DAManualEntryPointSelection, Enable-DAManualEntryP...
Script 3.0 Dism {Add-AppxProvisionedPackage, Add-WindowsDriver, Add-Windows...
Manifest 1.0.0.0 DnsClient {Resolve-DnsName, Clear-DnsClientCache, Get-DnsClient, Get-...
Manifest 1.0.0.0 EventTracingManagement {Start-EtwTraceSession, New-EtwTraceSession, Get-EtwTraceSe...
Manifest 2.0.0.0 International {Get-WinDefaultInputMethodOverride, Set-WinDefaultInputMeth...
Manifest 1.0.0.0 iSCSI {Get-IscsiTargetPortal, New-IscsiTargetPortal, Remove-Iscsi...
Script 1.0.0.0 ISE {New-IseSnippet, Import-IseSnippet, Get-IseSnippet}
Manifest 1.0.0.0 Kds {Add-KdsRootKey, Get-KdsRootKey, Test-KdsRootKey, Set-KdsCo...
Manifest 1.0.1.0 Microsoft.PowerShell.Archive {Compress-Archive, Expand-Archive}
Manifest 3.0.0.0 Microsoft.PowerShell.Diagnostics {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter...}
Manifest 3.0.0.0 Microsoft.PowerShell.Host {Start-Transcript, Stop-Transcript}
Manifest 1.0.0.0 Microsoft.PowerShell.LocalAccounts {Add-LocalGroupMember, Disable-LocalUser, Enable-LocalUser,...
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}
Script 1.0 Microsoft.PowerShell.ODataUtils Export-ODataEndpointProxy
Manifest 3.0.0.0 Microsoft.PowerShell.Security {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential...}
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Format-List, Format-Custom, Format-Table, Format-Wide...}
Manifest 3.0.0.0 Microsoft.WSMan.Management {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSS...
Manifest 1.0 MMAgent {Disable-MMAgent, Enable-MMAgent, Set-MMAgent, Get-MMAgent...}
Manifest 1.0.0.0 MsDtc {New-DtcDiagnosticTransaction, Complete-DtcDiagnosticTransa...
Manifest 2.0.0.0 NetAdapter {Disable-NetAdapter, Disable-NetAdapterBinding, Disable-Net...
Manifest 1.0.0.0 NetConnection {Get-NetConnectionProfile, Set-NetConnectionProfile}
Manifest 1.0.0.0 NetEventPacketCapture {New-NetEventSession, Remove-NetEventSession, Get-NetEventS...
Manifest 2.0.0.0 NetLbfo {Add-NetLbfoTeamMember, Add-NetLbfoTeamNic, Get-NetLbfoTeam...
Manifest 1.0.0.0 NetNat {Get-NetNat, Get-NetNatExternalAddress, Get-NetNatStaticMap...
Manifest 2.0.0.0 NetQos {Get-NetQosPolicy, Set-NetQosPolicy, Remove-NetQosPolicy, N...
Manifest 2.0.0.0 NetSecurity {Get-DAPolicyChange, New-NetIPsecAuthProposal, New-NetIPsec...
Manifest 1.0.0.0 NetSwitchTeam {New-NetSwitchTeam, Remove-NetSwitchTeam, Get-NetSwitchTeam...
Manifest 1.0.0.0 NetTCPIP {Get-NetIPAddress, Get-NetIPInterface, Get-NetIPv4Protocol,...
Manifest 1.0.0.0 NetworkConnectivityStatus {Get-DAConnectionStatus, Get-NCSIPolicyConfiguration, Reset...
Manifest 1.0.0.0 NetworkSwitchManager {Disable-NetworkSwitchEthernetPort, Enable-NetworkSwitchEth...
Manifest 1.0.0.0 NetworkTransition {Add-NetIPHttpsCertBinding, Disable-NetDnsTransitionConfigu...
Manifest 1.0.0.0 PcsvDevice {Get-PcsvDevice, Start-PcsvDevice, Stop-PcsvDevice, Restart...
Manifest 1.0.0.0 PKI {Add-CertificateEnrollmentPolicyServer, Export-Certificate,...
Manifest 1.0.0.0 PnpDevice {Get-PnpDevice, Get-PnpDeviceProperty, Enable-PnpDevice, Di...
Manifest 1.1 PrintManagement {Add-Printer, Add-PrinterDriver, Add-PrinterPort, Get-Print...
Script 3.0 Provisioning {Install-ProvisioningPackage, Export-ProvisioningPackage, I...
Manifest 1.1 PSDesiredStateConfiguration {Set-DscLocalConfigurationManager, Start-DscConfiguration, ...
Script 1.0.0.0 PSDiagnostics {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSM...
Binary 1.1.0.0 PSScheduledJob {New-JobTrigger, Add-JobTrigger, Remove-JobTrigger, Get-Job...
Manifest 2.0.0.0 PSWorkflow {New-PSWorkflowExecutionOption, New-PSWorkflowSession, nwsn}
Manifest 1.0.0.0 PSWorkflowUtility Invoke-AsWorkflow
Manifest 1.0.0.0 ScheduledTasks {Get-ScheduledTask, Set-ScheduledTask, Register-ScheduledTa...
Manifest 2.0.0.0 SecureBoot {Confirm-SecureBootUEFI, Set-SecureBootUEFI, Get-SecureBoot...
Manifest 2.0.0.0 SmbShare {Get-SmbShare, Remove-SmbShare, Set-SmbShare, Block-SmbShar...
Manifest 2.0.0.0 SmbWitness {Get-SmbWitnessClient, Move-SmbWitnessClient, gsmbw, msmbw...}
Manifest 1.0.0.0 StartLayout {Export-StartLayout, Import-StartLayout, Export-StartLayout...
Manifest 2.0.0.0 Storage {Add-InitiatorIdToMaskingSet, Add-PartitionAccessPath, Add-...
Manifest 2.0.0.0 TLS {New-TlsSessionTicketKey, Enable-TlsSessionTicketKey, Disab...
Manifest 1.0.0.0 TroubleshootingPack {Get-TroubleshootingPack, Invoke-TroubleshootingPack}
Manifest 2.0.0.0 TrustedPlatformModule {Get-Tpm, Initialize-Tpm, Clear-Tpm, Unblock-Tpm...}
Manifest 2.0.0.0 VpnClient {Add-VpnConnection, Set-VpnConnection, Remove-VpnConnection...
Manifest 1.0.0.0 Wdac {Get-OdbcDriver, Set-OdbcDriver, Get-OdbcDsn, Add-OdbcDsn...}
Manifest 1.0.0.0 WindowsDeveloperLicense {Get-WindowsDeveloperLicense, Unregister-WindowsDeveloperLi...
Script 1.0 WindowsErrorReporting {Enable-WindowsErrorReporting, Disable-WindowsErrorReportin...
Manifest 1.0.0.0 WindowsSearch {Get-WindowsSearchSetting, Set-WindowsSearchSetting}
Manifest 1.0.0.0 WindowsUpdate Get-WindowsUpdateLog
Environment Data
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.15063.726
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.726
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Debug Output
ActivityId : 0
ParentActivityId : -1
Activity : Set-AzStorageBlobContent task status :
StatusDescription : Total: 1. Successful: 0. Failed: 0. Active: 1.
CurrentOperation :
PercentComplete : -1
SecondsRemaining : -1
RecordType : Processing
ActivityId : 1
ParentActivityId : -1
Activity : Upload file 'C:\Users\Client\Temp\Sample.csv' to blob 'Sample.csv' in container 'inventory'.
StatusDescription : Transmit failed. Exception: Failed to open file C:\Users\Client\Temp\Sample.csv: Illegal characters
in path...
CurrentOperation :
PercentComplete : 0
SecondsRemaining : -1
RecordType : Processing
ActivityId : 0
ParentActivityId : -1
Activity : Set-AzStorageBlobContent task status :
StatusDescription : Total: 1. Successful: 0. Failed: 0. Active: 1.
CurrentOperation :
PercentComplete : -1
SecondsRemaining : -1
RecordType : Completed
Transfer Summary
--------------------------------
Total: 1.
Successful: 0.
Failed: 1.
@yeswps
I can't repro the issue on my machine, I tried 2 machines. But I see an issue on you machine, you have both old storage module "Azure.Storage"/"AzureRm.Storage", and new storage module "Az.Storage" loaded, there might be some conflict.
Would you please help to remove all the modules and reinstall Azure Powershell, then try again :
- Remove all installed module
Azure.*,Az.*from C:\Program Files\WindowsPowerShell\Modules (from PowerShell 5.1), C:\Program Files\PowerShell\Modules (for PowerShell 6.*)
-
To check if you have any AzureRM.* modules installed on your machine, run the following command:
Get-Module -Name AzureRM.* -ListAvailable -
To check if you have any Az.* modules installed on your machine, run the following command:
Get-Module -Name Az.* -ListAvailable
-
Install the Azure Powershell by running the following commands :
Install-Module -Name Az -Repository PSGallery -Force -
Open a new Powershell console, and try to repro the issue.
If you still can repro the issue, could you help to collect more information by run following command just after Set-AzStorageBlobContent fail, and show me the result (hide if any credntial)
$error[0].Exception.ToString()
[environment]::OSVersion
Get-Childitem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'
get-module
@blueww
The environment is in Azure Automation Account. I tried to remove Azure.Storage and AzureRM.Storage, but only found out that they were revered to previous versions that shipped with Azure Automation Account
Azure.Storage 4.6.1 has been downgraded to 1.0.3 AzureRM.Storage 5.2.0 has been downgraded to 1.0.3
There seems to have no way for me to completely remove Azure.Storage and AzureRM.Storage as they are both listed as Global Module. As such I cannot complete your request to remove all Azure.* and AzureRM.* module.
$error[0].Exception.ToString()
Microsoft.WindowsAzure.Storage.DataMovement.TransferException: Failed to open file C:\Users\Client\Temp\Sample.csv: Illegal characters in path.. ---> System.ArgumentException: Illegal characters in path.
at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath)
at Microsoft.WindowsAzure.Storage.DataMovement.LongPath.ToUncPath(String path)
at Microsoft.WindowsAzure.Storage.DataMovement.TransferControllers.StreamedReader.<OpenInputStreamAsync>d__18.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.Storage.DataMovement.TransferControllers.StreamedReader.<OpenInputStreamAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WindowsAzure.Storage.DataMovement.TransferControllers.StreamedReader.<DoWorkInternalAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WindowsAzure.Storage.DataMovement.TransferControllers.SyncTransferController.<DoWorkInternalAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WindowsAzure.Storage.DataMovement.TransferControllers.TransferControllerBase.<DoWorkAsync>d__33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WindowsAzure.Storage.DataMovement.TransferScheduler.<ExecuteJobInternalAsync>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WindowsAzure.Storage.DataMovement.SingleObjectTransfer.<ExecuteAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WindowsAzure.Storage.DataMovement.TransferManager.<DoTransfer>d__72.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WindowsAzure.Commands.Storage.Common.DataMovementTransferHelper.<DoTransfer>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WindowsAzure.Commands.Storage.Blob.SetAzureBlobContentCommand.<Upload2Blob>d__45.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WindowsAzure.Commands.Storage.Common.LimitedConcurrencyTaskScheduler.<RunConcurrentTask>d__26.MoveNext()
Platform ServicePack Version VersionString
-------- ----------- ------- -------------
Win32NT 6.2.9200.0 Microsoft Windows NT 6.2.9200.0
Get-Childitem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' Hive: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
Name Property
---- --------
1033 CBS : 1
Install : 1
Release : 461808
Servicing : 0
TargetVersion : 4.0.0
Version : 4.7.03056
get-module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.2.1 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Conne...
Script 1.0.2 Az.Storage {Add-AzRmStorageContainerLegalHold, Add-AzStorageAccountNet...
Binary 1.0 Orchestrator.AssetManagement.Cmd... {Get-AutomationCertificate, Get-AutomationConnection, Get-A...
Script 0.0 Orchestrator.GraphRunbook.Cmdlets {Invoke-RunbookFlow, New-RunbookFlowJunction, New-RunbookFl...
@blueww
Just came across this article, which explains that Az module is currently not available in Azure Automation account, until after March 15, 2019
Azure PowerShell ‘Az’ Module version 1.0
Azure Automation support The Az module can run in Windows PowerShell 5.1, but requires .NET Framework version 4.7.2 or later. Azure Automation cloud workers currently support .NET Framework version 4.6.1. Azure Automation is updating their cloud workers to support .NET version 4.7.2, and until these new workers are deployed, Az cannot be used in Azure Automation cloud runbooks.
The Azure Automation team plans to deploy cloud workers supporting .NET 4.7.2 to all Azure environments and regions by March 15, 2019. You should expect to see more announcements as this rollout progresses in the new year. You can find more information on the Az announcement page.
Now the wield part is, my Windows 7 machine have following dot.net version, yet it doesn't have the same issue:
Name Property
---- --------
1033 Version : 4.7.03062
TargetVersion : 4.0.0
Install : 1
Servicing : 0
Release : 461814
@vrdmr Can you take a look at this issue?
@yeswps
We have repro the same issue in runbook, and find it's caused by the difference behavior of API [System.IO.Path]::GetFullPath() on different machine.
In DMlib (Powershell Depends on DMlib for blob upload/download), for support long file path, DMlib will convert local file path to UNC path format, and then do transfer. But on your machine, it seems the API not support UNC path, but on my machine, it support UNC path. I will contact netcore team to check the API issue. Will update you if get any result from them.
On my local machine (not repro the issue), the API works correctly:
PS C:\WINDOWS\system32> [System.IO.Path]::GetFullPath("\\?\c:\test.csv")
\\?\c:\test.csv
On Runbook (which repro the issue), the API report error:
Script:
[System.IO.Path]::GetFullPath("\\?\c:\test.csv")
Result:
Exception calling "GetFullPath" with "1" argument(s): "Illegal characters in path."
At line:2 char:1
+ [System.IO.Path]::GetFullPath("\\?\c:\test.csv")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentException
@blueww
There doesn't appear to have a way to change UseLegacyPathHandling setting during the execution, and there's no way for us to change the default behavior of Azure Automation Runbook...
A similar issue seems to occur with Get-AzStorageBlobContent too. Again in Azure Automation.
Get-AzStorageBlobContent : Illegal characters in path.
At C:\Temp\yih4h5qs.1qd\Restore-Workspace.ps1:43 char:5
+ Get-AzStorageBlobContent -Container $AzureStorageAccountContainer ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-AzStorageBlobContent], ArgumentException
+ FullyQualifiedErrorId :
ArgumentException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageBlobContentCommand
Based on #8473, it sounds like an OS upgrade resolves this issue by changing the default path handling preference. Does anyone know if this change was made in Windows Server too, and if so, timelines the agents would be upgraded?
@yeswps , @brent-robinson We are discussing with Automation team for how to resolve the issue. Will update you if any progress.
Before the issue is resolved, can you use the old cmdlets in Azure.Storage module, or use the Storage Client library upload blob API directly in script?
Switching to the Azure.Storage PowerShell module is a successful workaround for this issue.
I have the same issue when running a runbook in a Hybrid Worker which has .Net 4.7.2 installed. By switching to the old Azure.Storage module I need to use all the old RM Modules as well and cant get started with Azure AZ...
Automation team is working to fix the issue in runbbok.
Glad to see this is getting fixed. I'm new to Azure Automation with Hybrid Workers and new to using the Az module and getting this error was frustrating and making me doubt I was doing anything right.
Is there any timeline on this fix?
The fix on the Azure Automation service side is being deployed now, and is already available in some regions. ETA for all regions: 3/31.
Please note, however, that the fix is relevant for cloud jobs only. If Hybrid Runbook Workers are affected as well, this may require a separate fix.
The fix for cloud Azure Automation jobs is rolled out to all regions.
Hybrid jobs need to be handled separately. We are working on getting the timeline for the fix on the Azure Automation side. In the meantime, the temporary workaround could be to create a file named ~~OrchestratorSandbox.exe.config~~ Orchestrator.Sandbox.exe.config with the following content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false" />
</runtime>
</configuration>
Put this file to the same folder on the Hybrid Runbook Worker where ~~OrchestratorSandbox.exe~~ Orchestrator.Sandbox.exe is located.
@yeswps , @brent-robinson, @ronhowe , @skaarup1986 As the Automation Runbook is fixed , and Hybrid jobs has workaround, I will close the issue now. Feel free to contact us if you need any more assistant from us.
The fix for cloud Azure Automation jobs is rolled out to all regions.
Hybrid jobs need to be handled separately. We are working on getting the timeline for the fix on the Azure Automation side. In the meantime, the temporary workaround could be to create a file named OrchestratorSandbox.exe.config with the following content:
<?xml version="1.0" encoding="utf-8"?> <configuration> <runtime> <AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false" /> </runtime> </configuration>Put this file to the same folder on the Hybrid Runbook Worker where OrchestratorSandbox.exe is located.
Actually, the filename is Orchestrator.Sandbox.exe which may help people find the file to apply this fix. I ended up finding it with
Get-ChildItem -Path \ -Filter *Sandbox*.exe -Recurse -ErrorAction SilentlyContinue -Force
This did correct my issue on my Hybrid Runbook Worker — thanks!
Actually, the filename is Orchestrator.Sandbox.exe which may help people find the file to apply this fix.
Thank you, Orchestrator.Sandbox.exe and Orchestrator.Sandbox.exe.config are the correct names.
@AnatoliB @blueww This issue was resolved for me when running Set-AzStorageBlobContent in automation account runbook. I still have two runbooks in the same automation account works fine.
However, the same error occurred when using Hybrid Worker. I've created Orchestrator.Sandbox.exe.config in the same folder where Orchestrator.Sandbox.exe existed, upgraded AZ powershell, rebooted Hybrid Worker VM. And the error persists.
@yeswps I would suggest creating a support request for the Azure Automation service. They should be able to help you with troubleshooting this.