Question:
I am creating a Azure workflow runbook wherein I have to get a file from Azure File System Storage and publish that to a azure web app.
I tried with New-PSDrive but that command is not supported in runbook (even InlineScript doesn’t work). Could anyone help me with the script. In the below code I need to populate file path from azure file system.
1 2 3 4 5 6 7 |
$Conn = Get-AutomationConnection -Name AzureRunAsConnection Connect-AzureRmAccount -ServicePrincipal -Tenant $Conn.TenantID ` -ApplicationId $Conn.ApplicationID ` -CertificateThumbprint $Conn.CertificateThumbprint $zipFilePath = ??? Publish-AzureWebsiteProject -Name $siteName -Package $zipFilePath |
I searched a lot but couldn’t find much information on this.
Answer:
Are you referring to a file in a Azure Storage account? If so, that is pretty easy to accomplish. Add the following to your Runbook, filling in the required information:
1 2 3 4 5 6 7 8 9 10 |
$StorageAccountKey = Get-AutomationVariable -Name 'storageKey' $Context = New-AzureStorageContext -StorageAccountName 'your-storage' ` -StorageAccountKey $StorageAccountKey Get-AzureStorageFileContent -ShareName 'your-share' -Context $Context ` -path 'your-file' -Destination 'C:\Temp' $filePath = Join-Path -Path 'C:\Temp' -ChildPath 'your-file' |
You also need to create an variable in your Automation Account, called “storageKey” containing your Storage Accounts key.