Skip to content
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

Export-AzAutomationRunbook Adding extra '\' to file names. #11101

Closed
AndreasMWalter opened this issue Feb 11, 2020 · 15 comments
Closed

Export-AzAutomationRunbook Adding extra '\' to file names. #11101

AndreasMWalter opened this issue Feb 11, 2020 · 15 comments
Labels
Automation customer-reported Service Attention This issue is responsible by Azure service team.

Comments

@AndreasMWalter
Copy link

Description

I am currently running into an issue using a PowerShell script on the ubuntu18.04 worker in Azure DevOps.

This issue was reported as fixed in #6999

Steps to reproduce

You need a runbook that you want to export from any automation account

$Runbook = Get-AzAutomationRunbook -ResourceGroupName $ResourceGroup -AutomationAccountName $AutomationAccountName
$TemporaryFolder = $env:SYSTEM_DEFAULTWORKINGDIRECTORY + '/temp/'
$Runbook | Export-AzAutomationRunbook -OutputFolder $TemporaryFolder -Force 

Environment data

Key   : PSVersion
Value : 6.2.4
Name  : PSVersion


Key   : PSEdition
Value : Core
Name  : PSEdition


Key   : GitCommitId
Value : 6.2.4
Name  : GitCommitId


Key   : OS
Value : Linux 5.0.0-1028-azure #30~18.04.1-Ubuntu SMP Fri Dec 6 11:47:59 UTC 
        2019
Name  : OS


Key   : Platform
Value : Unix
Name  : Platform


Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0…}
Name  : PSCompatibleVersions


Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion


Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion


Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion

Module versions

I have reduced the Module output to the Az.Automation module, rest can be found on the worker see above

Name              : Az.Automation
Path              : /usr/share/az_3.1.0/Az.Automation/1.3.4/Az.Automation.psd1
Description       : Microsoft Azure PowerShell - Automation service cmdlets 
                    for Azure Resource Manager in Windows PowerShell and 
                    PowerShell Core.
                    
                    For more information on Automation, please visit the 
                    following: https://docs.microsoft.com/azure/automation/
Guid              : ef36c942-4a71-4e19-9450-05a35843deb6
Version           : 1.3.4
ModuleBase        : /usr/share/az_3.1.0/Az.Automation/1.3.4
ModuleType        : Script
PrivateData       : {PSData}
AccessMode        : ReadWrite
ExportedAliases   : {[Import-AzAutomationModule, Import-AzAutomationModule]}
ExportedCmdlets   : {[Get-AzAutomationHybridWorkerGroup, 
                    Get-AzAutomationHybridWorkerGroup], 
                    [Remove-AzAutomationHybridWorkerGroup, 
                    Remove-AzAutomationHybridWorkerGroup], 
                    [Get-AzAutomationJobOutputRecord, 
                    Get-AzAutomationJobOutputRecord], 
                    [Import-AzAutomationDscNodeConfiguration, 
                    Import-AzAutomationDscNodeConfiguration]…}
ExportedFunctions : {}
ExportedVariables : {}
NestedModules     : {}

Debug output

Error output

image

@wyunchi-ms wyunchi-ms added Automation Service Attention This issue is responsible by Azure service team. and removed triage labels Feb 12, 2020
@ghost
Copy link

ghost commented Feb 12, 2020

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @zjalexander

1 similar comment
@ghost
Copy link

ghost commented Feb 12, 2020

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @zjalexander

@dingmeng-xue
Copy link
Member

@AndreasMWalter, I didn't get the meaning of the last snapshot. What's the output folder resolved by cmdlet?

@AndreasMWalter
Copy link
Author

AndreasMWalter commented Feb 12, 2020

Dear @dingmeng-xue
The screenshot depicts the filename of the Runbook within the output folder, note the backslash at the front of the filename.
Needless to say, there should not be a backslash.
The outputfolder is:
$TemporaryFolder = $env:SYSTEM_DEFAULTWORKINGDIRECTORY + '/temp/'
The filename is:
'\Invoke-RunbookName.ps1'

The filename should be:
'Invoke-RunbookName.ps1'

Now I have been experimenting with this yesterday and there have been several interesting results:

My Original Call was (without changing the script from Windows File references):

Export-AzAutomationRunbook -OutputFolder .\temp

Since I was in the working directory, the expected behaviour of above call was:
Place the exported runbook here:
$env:SYSTEM_DEFAULTWORKINGDIRECTORY\temp\Invoke-Runbook.ps1

Now this was not what happened, however for some reason the runbook was placed here:

$env:SYSTEM_DEFAULTWORKINGDIRECTORY\temp\ 'temp\Invoke-Runbook.ps1'

However 'temp\Invoke-Runbook.ps1' being the filename of the runbook for some odd reason.
image

So I did some troubleshooting of the pipeline and made sure that the path were all Linux paths etc. and I reference environment variables where I could and the result was that the Export-AzAutomationRunbook cmdlet adds a ' \ ' at the beginning of the runbook name, as depicted in my earlier screenshot and reported in the issue #6999 .

@ghost
Copy link

ghost commented Feb 13, 2020

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @zjalexander

@dingmeng-xue
Copy link
Member

Automation team, please check if file path should be resolved according to common ResolveUserPath api.

var outputFilePath = outputFolderFullPath + "\\" + runbookName + fileExtension;

@vikram-m
Copy link

vikram-m commented Jul 9, 2020

This is triaged and currently in the backlog, will consider it if resourcing allows.

@vikram-m
Copy link

Unfortunately because of other priorities we were not able to pick this up, please expect an update in Q4CY20.

@vikram-m
Copy link

Currently, team is busy with other high priority items and this would be picked up in CY2021 Q1.

@achaika80
Copy link

I'm experiencing this Issue as well on MacOS Catalina 10.16.7
PowerShell 7.1
Az.Automation 1.4.0

@achaika80
Copy link

I put together script to work around this issue while there is no official fix:
https://github.com/achaika80/Powershell/tree/master/Get-RunbooksFromAzureAA

@KranthiPakala-MSFT
Copy link

@vikram-m Following up to see if there is any update on this issue? - Thank you

@navba-MSFT
Copy link
Contributor

@AndreasMWalter Apologies for the delay in response. This github thread has been open for quite sometime now. I just wanted to check if you still need assistance on this issue. Awaiting your reply.

@vikram-m Could you please update us regarding the status of the fix ?

@navba-MSFT navba-MSFT assigned navba-MSFT and unassigned navba-MSFT Jan 31, 2022
@navba-MSFT
Copy link
Contributor

I am following up with the Engineering team regarding the fix. This thread will be updated once we have more details.

@Jassingh819
Copy link
Contributor

Closed with above PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Automation customer-reported Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

8 participants