从 Visual Studio 在线部署 Azure 云服务

Deploy Azure Cloud Service from Visual Studio Online

我们能否将 Azure 云服务部署设置为构建过程的一部分,以获得与 Visual Studio 向导给出的类似结果?

UPD. 我们找到了 "Azure Cloud Service Deployment" 构建步骤,但失败并出现以下意外错误(因为实际设置了存储帐户,请参阅下面的完整日志)。

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

完整日志:

Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\tasks\AzureCloudPowerShellDeployment.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.

在尝试任何命令之前,您需要设置并登录订阅。

我通常将它作为我的 PowerShell 的一部分,如果您四处搜索,您会发现如何加密您的凭据,使它们不在脚本中。

我们终于成功完成了 "Azure PowerShell" 通用构建步骤和使用 Azure API 的自定义 PS 脚本到 create/update Azure 部署(New-AzureDeploymentSet-AzureDeployment).

包含完整脚本的精彩文章位于:http://www.kenneth-truyers.net/2014/02/06/deploying-cloud-services-to-azure-with-powershell/