-
Notifications
You must be signed in to change notification settings - Fork 4k
Set-AzStorageBlobContent throws error when trying to open file #8473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@fmicle Would you like to check do you have any invisible special char in the path? PS C:\dev\pq\service\scripts\azure\NestedTemplates> Set-AzStorageBlobContent -Container "florin-container" -Context $ctx -File "ApplicationInsights.json"
Container Uri: https://weistagelarge.blob.core.windows.net/florin-container
Name BlobType Length ContentType LastModified AccessTier SnapshotTime IsDeleted
---- -------- ------ ----------- ------------ ---------- ------------ ---------
ApplicationInsigh... BlockBlob 492476 application/octet-stream 2019-02-11 08:12:49Z Hot False
PS C:\dev\pq\service\scripts\azure\NestedTemplates> get-module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.2.1 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount...}
Script 1.0.2 Az.Storage {Add-AzRmStorageContainerLegalHold, Add-AzStorageAccountNetworkRule, Disable-AzStorageDeleteRetentionPolicy, Disable-AzStorageStaticW...
Script 1.0.0.0 ISE {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest 3.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest 3.0.0.0 Microsoft.WSMan.Management {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP...} |
I just tried again today, I removed the AzureRM modules, installed Az modules, executed Enable-AzureRmAlias and without making any other changes to my scripts I am seeing the same problem: Set-AzureStorageBlobContent : Failed to open file C:\dev\pq\service\scripts\azure\NestedTemplates\ApplicationInsights.json: Illegal characters in path.. There are no invisible characters in the path, since everything works as expected when using the AzureRM scripts... |
I created a very simple test case scenario, outside of our bigger script suite and can very easily recreate the problem. I put a file called test.json in c:, it contains an empty json object, just the curly braces, as you can see in the output below. I am using the AzureRM Alias scenario:
|
We are facing this issue from a PS automation context. What appear to be straightforward paths which used to work with the equivalent AzureRm cmdlet in the past are failing with the above error after changing to Set-AzStorage version. |
I can't repro the issue on my machine, I tried 2 machines.
BTW, does this issue always happen when you upload any file with Set-AzStorageBlobContent, or only on specific files? From your comments, it looks like always repro? |
Yes, I can repro consistently on first attempt, and it happens with any file I try.
|
I see another customer which repro the issue in runbook: #8531 We have repro the same issue in runbook, and find it's caused by the difference behavior of API Would you please check if the following command will report error on your 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:
On Runbook (which repro the issue), the API report error:
|
Yes, the error occurs on my local machine:
|
The issue is now narrowed down to 'legacy path handing' settings in .Net. For me the issue repros from a PS runbook using Az-* but does not repro from my desktop (using the same code). Inspecting the relevant setting in the two environments gives me this: $x = "blah" Output from Runbook: Output on Desktop: |
@fmicle It's most likely the switch that enables device syntax isn’t set. While .NET 4.6.2+ supports the extended syntax, PowerShell (not Core) didn’t opt into it until the Windows 10 Anniversary update. While PowerShell hosts the CLR it does specify the config file when creating the AppDomain. It will pass C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.config. You can explicitly set the flags the “normal” way by: https://blogs.msdn.microsoft.com/jeremykuhne/2016/06/09/new-net-path-handling-sneak-peek/ I have tested:
So you might need to make sure:
Let me know if you get any update on this. @mprabhu11 |
For some reason the Windows 10 Anniversary update has been failing to install on my laptop since the day it was published. I tried a few tricks, but nothing worked, so I guess I need to take my laptop to IT, since my domain policy doesn't allow me to install updates manually... I also tried the powershell.exe.config route and I can't get the setting to change... |
@fmicle |
I'm still having issues with this. Here are the contents of my powershell.exe.config.
I run the following as a test:
When I run that while RDP'd into my Azure Automation Hybrid Worker, I get $false. When I run that remotely on that Azure Automation Hybrid Worker via a Runbook, I get $true. |
@ronhowe You might can use the old cmdlet in Azure.Storage module as a workaround. |
@ronhowe , @fmicle , @mprabhu11 The fix for cloud Azure Automation jobs is rolled out to all regions. And the automation runbook is fixed, I plan to close the issue. Let me know if you have any concent. |
This still is not working for me. How do you fix with Get-AzStorageBlobontent? I removed the powershell.exe.config file as stated in https://blogs.msdn.microsoft.com/jeremykuhne/2016/06/09/new-net-path-handling-sneak-peek/. Perhaps i am missing something but when i run: so ho do i change that to false? this is for Desktop |
The script above returns true for me as well, but the actual problem got fixed for me a while ago. Try creating this registry key: $registryPath = "HKLM:\SOFTWARE\Microsoft.NETFramework\AppContext" |
Hi All, How to fix this illegal path issue? I am facing this issue when I trying to call Get-AzureStorageBlobContent. Please suggest to me. Recently I have uninstalled AzureRm and installed Az Module with Enable AzureRM Alias. Thanks |
Bit frustrated after spending almost a day to get this working in hybrid Worker. I tried all the options mentioned here, i.e. update the registry and updated the powershell.exe.config file as well. none of this worked for me. Raised a formal ticket to Microsoft. |
Description
I am migrating our Azure deployment scripts from AzureRM to Az and I ran into a problem with Set-AzStorageBlobContent throwing an error when trying to open the Azure template file. These Azure templates have been working and change very rarely. I tried full file name with backslashes, full name with forward slashes, relative file name without any special characters from the current template folder, in every situation the file name is resolved correctly to the full name, but it cannot be opened. It complains about "Illegal characters in path."
Script/Steps for Reproduction
Module Version
Environment Data
Debug Output
The text was updated successfully, but these errors were encountered: