Upload Cloud Service configuration file to Azure storage blob

We use Azure Cloud Service step and during that step only cspkg file is uploaded to a Azure Blob storage. We would like to also upload cscfg file so that we can install the transformed package and configuration to any other Cloud Service manually. We use Octopus Deploy variables in configuration to set settings and network configuration through variable sets.

Thank you

Hi Alex,

Thanks for getting in touch! Not really sure why the cscfg is not being uploaded. Are you able to provide a screen shot of your NuGet package contents?
Could you also please provide a full deployment log. http://docs.octopusdeploy.com/display/OD/Get+the+raw+output+from+a+task

Hopefully this will help us figure out what is going on.

Thanks,
Daniel

Hello Daniel,

Attached is the screenshot of Nuget package. Below is the the partial raw output. Notice that only cspkg is being uploaded, ServiceConfiguration.Cloud.cscfg stays in Octopus Deploy temp folder. Temp folder is deleted after Azure Cloud Service step completes. The ServiceConfiguration.Cloud.cscfg in the nuget package cannot be used because it contains variables that need to be transformed by the Azure Cloud Service step. Thank you.

22:47:45 Verbose | Uploading package to Azure blob storage: ‘E:\OctopusHome\Work\20160411224732-171<deleted>.cspkg’
22:47:52 Verbose | Certificate was found in store
22:47:53 Verbose | Uploading, response received: 202 Accepted
22:47:53 Verbose | Uploading the package to blob storage. The package file is 34 MB.
22:47:53 Verbose | Uploading package to blob storage: 1024 KB of 34 MB
22:47:53 Verbose | Uploading package to blob storage: 2 MB of 34 MB
22:47:53 Verbose | Uploading package to blob storage: 3 MB of 34 MB
22:47:54 Verbose | Uploading package to blob storage: 4 MB of 34 MB
22:47:54 Verbose | Uploading package to blob storage: 5 MB of 34 MB
22:47:54 Verbose | Uploading package to blob storage: 6 MB of 34 MB
22:47:54 Verbose | Uploading package to blob storage: 7 MB of 34 MB
22:47:54 Verbose | Uploading package to blob storage: 8 MB of 34 MB
22:47:54 Verbose | Uploading package to blob storage: 9 MB of 34 MB
22:47:55 Verbose | Uploading package to blob storage: 10 MB of 34 MB
22:47:55 Verbose | Uploading package to blob storage: 11 MB of 34 MB
22:47:55 Verbose | Uploading package to blob storage: 12 MB of 34 MB
22:47:55 Verbose | Uploading package to blob storage: 13 MB of 34 MB
22:47:55 Verbose | Uploading package to blob storage: 14 MB of 34 MB
22:47:56 Verbose | Uploading package to blob storage: 15 MB of 34 MB
22:47:56 Verbose | Uploading package to blob storage: 16 MB of 34 MB
22:47:56 Verbose | Uploading package to blob storage: 17 MB of 34 MB
22:47:56 Verbose | Uploading package to blob storage: 18 MB of 34 MB
22:47:56 Verbose | Uploading package to blob storage: 19 MB of 34 MB
22:47:56 Verbose | Uploading package to blob storage: 20 MB of 34 MB
22:47:56 Verbose | Uploading package to blob storage: 21 MB of 34 MB
22:47:57 Verbose | Uploading package to blob storage: 22 MB of 34 MB
22:47:57 Verbose | Uploading package to blob storage: 23 MB of 34 MB
22:47:57 Verbose | Uploading package to blob storage: 24 MB of 34 MB
22:47:57 Verbose | Uploading package to blob storage: 25 MB of 34 MB
22:47:57 Verbose | Uploading package to blob storage: 26 MB of 34 MB
22:47:57 Verbose | Uploading package to blob storage: 27 MB of 34 MB
22:47:58 Verbose | Uploading package to blob storage: 28 MB of 34 MB
22:47:58 Verbose | Uploading package to blob storage: 29 MB of 34 MB
22:47:58 Verbose | Uploading package to blob storage: 30 MB of 34 MB
22:47:58 Verbose | Uploading package to blob storage: 31 MB of 34 MB
22:47:58 Verbose | Uploading package to blob storage: 32 MB of 34 MB
22:47:58 Verbose | Uploading package to blob storage: 33 MB of 34 MB
22:47:58 Verbose | Uploading package to blob storage: 34 MB of 34 MB
22:47:58 Verbose | Uploading package to blob storage: 34 MB of 34 MB
22:47:58 Verbose | Upload complete
22:47:58 Info | Package upload complete
22:47:58 Info | Package uploaded to https://.blob.core.windows.net/octopuspackages/_55c7a8f5178ef65b3834bc4399e30e8233954181.cspkg
22:47:58 Info | Config file: E:\OctopusHome\Work\20160411224732-171\ServiceConfiguration.Cloud.cscfg

Hi Alex,

You are right, sorry we misread your first ticket. We don’t upload the config file, we only run it. So I got some help from one of our devs, he wrote the following that you can put in a post deploy script.

$ContainerName = "octopuspackages"
$StorageAccount = "#{Octopus.Action.Azure.StorageAccountName}"
$StorageKey = (Get-AzureStorageKey -StorageAccountName $StorageAccount).Primary
$ConfigFile = "#{OctopusAzureConfigurationFile}"
#Use whatever naming format you wish for the blob-name
$BlobName = "#{Octopus.Action.Package.NuGetPackageId}" + "." + "#{Octopus.Action.Package.NuGetPackageVersion}" + ".cscfg"
$Context = New-AzureStorageContext -StorageAccountName $StorageAccount -StorageAccountKey $StorageKey
Write-Output "Uploading $ConfigFile as $BlobName"
Set-AzureStorageBlobContent -Container $ContainerName -File $ConfigFile -Blob $BlobName -Context $Context -Properties @{ContentType="text/xml"} -Force

This will allow you to upload the file using our variables, let me know how you go :slight_smile:

Thanks,
Daniel

Thank you Daniel and the dev team!

Hi Alex,

No worries, I’m glad we were able to help!

Regards,
Daniel