Eugene D. Gubenkov
Eugene D. Gubenkov

Reputation: 5357

Deploy Azure Cloud Service from Visual Studio Online

Can we setup Azure Cloud Service deployment as a part of the build process to have a similar result that Visual Studio wizard gives?

VS Publish Cloud Service Wizard

UPD. We found "Azure Cloud Service Deployment" build step, but it fails with following unexpected error (because storage account is set actually, see the full log below).

Build step

CurrentStorageAccountName is not set. Use Set-AzureSubscription
subname -CurrentStorageAccountName storageaccount to set it.

The full log:

Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\tasks\AzureCloudPowerShellDeployment\1.0.13\Publish-AzureCloudDeployment.ps1
Looking for Azure PowerShell module at C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.psd1
AzurePSCmdletsVersion= 0.9.1
Get-ServiceEndpoint -Name ***cut** -Context Microsoft.TeamFoundation.DistributedTask.Agent.Worker.Common.TaskContext
Username= ***cut**
Add-AzureAccount -Credential $psCredential
azureSubscriptionId= ***cut**
azureSubscriptionName= ***cut**
Select-AzureSubscription -SubscriptionId ***cut**
ConnectedServiceName= ***cut** 
ServiceName= ***cut**
ServiceLocation= East US
StorageAccount= ***cut**
CsPkg= C:\a\c409f63f\***cut**.cspkg
CsCfg= C:\a\c409f63f\***cut**.cscfg
Slot= Production
AllowUpgrade= true
Find-Files -SearchPattern C:\a\c409f63f\***cut**.cscfg
serviceConfigFile= C:\a\c409f63f\***cut**.cscfg
Find-Files -SearchPattern C:\a\c409f63f\***cut**.cspkg
servicePackageFile= C:\a\c409f63f\***cut**.cspkg
Get-AzureService -ServiceName ***cut** -ErrorAction SilentlyContinue
Applying any configured diagnostics extensions.
New-AzureServiceDiagnosticsExtensionConfig -Role ***cut** -StorageContext  -DiagnosticsConfigurationPath C:\a\c409f63f\***cut**.xml
New-AzureServiceDiagnosticsExtensionConfig -Role ***cut** -StorageContext  -DiagnosticsConfigurationPath C:\a\c409f63f\***cut**.xml
Get-AzureDeployment -ServiceName crgd-scheduler -Slot Production -ErrorAction SilentlyContinue
Set-AzureDeployment -Upgrade -ServiceName ***cut** -Package C:\a\c409f63f\***cut**.cspkg -Configuration C:\a\c409f63f\***cut**.cscfg -Slot Production -ExtensionConfiguration 
CurrentStorageAccountName is not set. Use Set-AzureSubscription subname -CurrentStorageAccountName storageaccount to set it.

Upvotes: 2

Views: 1239

Answers (2)

Eugene D. Gubenkov
Eugene D. Gubenkov

Reputation: 5357

We finally succeeded with "Azure PowerShell" generic build step and the custom PS script that uses Azure API to create/update Azure deployment (New-AzureDeployment, Set-AzureDeployment).

vso build step

The great article that contains the full script is here: http://www.kenneth-truyers.net/2014/02/06/deploying-cloud-services-to-azure-with-powershell/.

Upvotes: 1

You need to setup and login to the subscription before you try any commands.

I usually make it part of my PowerShell, and if you search around you can find out how to encrypt your credentials to not have them in the script.

Upvotes: 0

Related Questions