Open ghost opened 8 years ago
Have you thought about checking in to Git from your local machine, instead of from Azure Automation? Then you won't need to go to the Automation portal.
Thanks for the quick response. Good point. However it's not so much about going to the Azure Portal but that I don't want the leave ISE. Would like to do everything from ISE without ever leaving it.
You can use git from the PowerShell ISE. Please see http://virtualengine.co.uk/2015/git-and-the-powershell-ise/
You cloud import the below runbook also and use this to push your changes from your local git directly into Azure Automation. You can pass in a specific file or folder to $GitPath depending if you want all the files or just a single one. Thanks, Eamon
<# .SYNOPSIS Syncs a local git folder or specific file under source control into an Azure Automation account.
.DESCRIPTION Syncs a local git folder or specific file under source control into an Azure Automation account. All runbooks need to be in a single folder. This runbook needs to be run on a hybrid runbook worker where source control git folder is set up. It runs git pull -v to get the latest changes from the git repository
.PARAMETER ResourceGroup The name of the resource group for this automation account
.PARAMETER AutomationAccountName The name of the Automation account
.PARAMETER AzureOrgIdCredential A credential setting containing an Org Id username / password with access to this Azure subscription
.PARAMETER GitPath The local folder or file on the hybrid runbook worker where git is set up to pull latest changes into
.PARAMETER SubscriptionID The ID of the Azure subscription. Will default to current subscription if not provided. Optional Parameter.
.EXAMPLE .\Sync-GitFolder.ps1 -GitPath "c:\finance\source\runbooks" -ResourceGroup Finance -AutomationAccountName FinanceAccount -AzureOrgIdCredential AzureCred -SubscriptionID 'bcdd8138-bb95-4d6e-8e83-dsss706025359'
.NOTES AUTHOR: System Center Automation Team LASTEDIT: Jan 20h, 2016
Param ( [Parameter(Mandatory=$true)] [String] $ResourceGroup,
[Parameter(Mandatory=$true)]
[String] $AutomationAccountName,
[Parameter(Mandatory=$true)]
[String] $AzureOrgIdCredential,
[Parameter(Mandatory=$true)]
[String] $GitPath,
[Parameter(Mandatory=$false)]
[String] $SubscriptionID = $null
)
Push-Location
if (Test-Path $GitPath -pathtype leaf)
{
Set-Location (Split-Path $GitPath -Parent)
git pull -v
}
else
{
Set-Location $GitPath
git pull -v
}
Pop-Location
$AzureCred = Get-AutomationPSCredential -Name $AzureOrgIdCredential
if ($AzureCred -eq $null)
{
throw "Could not retrieve '$AzureOrgIdCredential' credential asset. Check that you created this first in the Automation service."
}
Login-AzureRMAccount -Credential $AzureCred | Write-Verbose
$Files = Get-ChildItem -Path $GitPath -Filter *.ps1
foreach ($File in $Files) { Write-Output("Syncing " + $File.FullName) $AST = [System.Management.Automation.Language.Parser]::ParseFile($File.FullName, [ref]$null, [ref]$null); If ($AST.EndBlock.Extent.Text.ToLower().StartsWith("workflow")) { Write-Verbose "File is a PowerShell workflow" $Runbook = Import-AzureRmAutomationRunbook -Path $File.FullName -AutomationAccountName $AutomationAccountName -ResourceGroupName $ResourceGroup -Type PowerShellWorkflow -Force -Published } Else { Write-Verbose "File is a PowerShell script" $Runbook = Import-AzureRmAutomationRunbook -Path $File.FullName -AutomationAccountName $AutomationAccountName -ResourceGroupName $ResourceGroup -Type PowerShell -Force -Published } Write-Verbose $Runbook.State }
Thanks for the advice. Guess I didn't formulate this well enough. I was no looking on how to do this integration (although appreciate the feedback!) but a 'button in ISE'. Actually a feature request.
I would also like to see this check-in process integrated into the ISE add-on. I've setup the workaround with pushing to github from my local machine outside of the ISE add-on and the process is definitely a bit cumbersome.
Great add-on, was missing this sooooo much. Spend some time working with this and am quite happy. What I'm missing is the possibility to perform a complete life cycle management with source control from within ISE. I have my Automation Account integrated with Git. I don't see a way to get the changes made in ISE into Git via the Automation Account integration. After 'Upload Draft' I would like to have another functionality corresponding to 'Check in' when in edit mode on the portal. The way it is now I seem to be forced to 'Upload Draft' in ISE and then switch to the portal and perform 'Check in'.