A runbook editor is an authoring interface for creating and modifying automation runbooks inside an Automation account. It combines IDE features such as autocomplete and syntax highlighting with access to stored automation assets. section 8.4.2
A practical workflow develops the main PowerShell functionality locally, imports the script into Azure Automation, and then adapts it to consume Automation variables and managed identity authentication. Local development speeds testing; portal editing supplies Azure Automation-specific integration. section 8.4
Use the editor to assemble an operational runbook by:
- Replacing hard-coded configuration with Automation variables inserted from the Assets pane. section 8.4.2
- Converting runtime inputs such as folder paths and container names into mandatory parameters. section 8.4.2
- Connecting with the runbook's managed identity instead of adding credential assets or passing secrets. section 8.4.2
- Testing through the Test Pane on a selected hybrid runbook worker, then checking the target storage account. section 8.4.2
ZIP archive upload runbook
A runbook can accept a folder path and blob container, find ZIP files, upload them to Azure Blob storage, and delete the local copies. Its editor-based version retrieves the subscription, resource group, and storage account from Automation variables, authenticates with managed identity, and runs on a hybrid worker. section 8.4.2 section 8.4
Listing 8.4 Upload-ZipToBlob
param(
[Parameter(Mandatory = $true)]
[string]$FolderPath,
[Parameter(Mandatory = $true)]
[string]$Container
)
$SubscriptionID = Get-AutomationVariable ` #1
-Name 'ZipStorage_SubscriptionID'
$ResourceGroupName = Get-AutomationVariable -Name 'ZipStorage_ResourceGroup'
$StorageAccountName = Get-AutomationVariable -Name 'ZipStorage_AccountName'
Connect-AzAccount -Identity #2
Set-AzContext -Subscription $SubscriptionID
$ChildItem = @{ #3
Path = $FolderPath
Filter = '*.zip'
}
$ZipFiles = Get-ChildItem @ChildItem
$AzStorageAccountKey = @{ #4
ResourceGroupName = $ResourceGroupName
Name = $StorageAccountName
}
$Keys = Get-AzStorageAccountKey @AzStorageAccountKey
$AzStorageContext = @{
StorageAccountName = $StorageAccountName
StorageAccountKey = $Keys[0].Value
}
$Context = New-AzStorageContext @AzStorageContext
$AzStorageContainer = @{ #5
Name = $Container
Context = $Context
ErrorAction = 'SilentlyContinue'
}
$containerCheck = Get-AzStorageContainer @AzStorageContainer
if(-not $containerCheck){
$AzStorageContainer = @{
Name = $Container
Context = $Context
ErrorAction = 'Stop'
}
New-AzStorageContainer @AzStorageContainer| Out-Null
}
foreach($file in $ZipFiles){
$AzStorageBlob = @{ #6
Container = $container
Blob = $file.Name
Context = $Context
ErrorAction = 'SilentlyContinue'
}
$blobCheck = Get-AzStorageBlob @AzStorageBlob
if (-not $blobCheck) {
$AzStorageBlobContent = @{ #7
File = $file.FullName
Container = $Container
Blob = $file.Name
Context = $Context
Force = $true
ErrorAction = 'Stop'
}
Set-AzStorageBlobContent @AzStorageBlobContent
Remove-Item -Path $file.FullName -Force
}
}
Inspect the complete Upload-ZipToBlob runbook listing, including parameters, Automation variable retrieval, managed-identity connection, file discovery, and storage setup. section 8.4.2
