microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.49k stars 2.61k forks source link

Cloud Service deployment fails with ARM-based storage account #12766

Closed adiun closed 4 years ago

adiun commented 4 years ago

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: AzureCloudPowerShellDeploymentV1

Environment

Account Name: adunnith at microsoft (Adi Unnithan) Organization: empowermd Team Project Name: IntelligentScribe Build Definition Name: RecorderBotService-CI-TEST Build Number: 20200426.6 Agent Specification: windows-2019

Issue Description

I was trying to use the cloud deployment task and it fails with an ARM-based storage account. The task looks like this:

 - task: AzureCloudPowerShellDeployment@1
    displayName: 'Bot Service Deploy: $(BotServiceName)'
    inputs:
        azureClassicSubscription: ${{ parameters.classicSubscription }}
        EnableAdvancedStorageOptions: true
        ARMConnectedServiceName: ${{ parameters.armBuildStorageSubscription }} 
        ARMStorageAccount: $(BuildStorageAccount)
        ServiceName: $(BotServiceName) 
        ServiceLocation: $(RegionName) 
        CsPkg: $(Pipeline.Workspace)/cspkg/**/*.cspkg
        CsCfg: $(Pipeline.Workspace)/cscfg/**/*.cscfg
        AppendDateTimeToLabel: true
        AllowUpgrade: true

When running this, the Set-AzureDeployment step errors out because CurrentStorageAccountName was not set for the subscription via Set-AzureSubscription.

##[debug]Exception:
##[debug]System.ArgumentException: CurrentStorageAccountName is not set. Use Set-AzureSubscription subname -CurrentStorageAccountName storageaccount to set it.
##[debug]   at Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.SetAzureDeploymentCommand.ExecuteCommand() in d:\workspace\powershell-sign\src\ServiceManagement\Compute\Commands.ServiceManagement\HostedServices\SetAzureDeployment.cs:line 217
##[debug]   at System.Management.Automation.CommandProcessor.ProcessRecord()
##[error]CurrentStorageAccountName is not set. Use Set-AzureSubscription subname -CurrentStorageAccountName storageaccount to set it.
##[debug]Processed: ##vso[task.logissue type=error]CurrentStorageAccountName is not set. Use Set-AzureSubscription subname -CurrentStorageAccountName storageaccount to set it.
##[debug]Processed: ##vso[task.complete result=Failed]

If I set up a new Classic Storage Account and don't use the ARM capabilities with this task like the following, then it succeeds:

 - task: AzureCloudPowerShellDeployment@1
    displayName: 'Recorder Bot Service Deploy: $(BotServiceName)'
    inputs:
        azureClassicSubscription: ${{ parameters.classicSubscription }}
        EnableAdvancedStorageOptions: false
        StorageAccount: classicstoragetest
        ServiceName: $(BotServiceName) 
        ServiceLocation: $(RegionName) 
        CsPkg: $(Pipeline.Workspace)/cspkg/**/*.cspkg
        CsCfg: $(Pipeline.Workspace)/cscfg/**/*.cscfg
        AppendDateTimeToLabel: true
        AllowUpgrade: true

Task logs

Feel free to email me at adunnith at microsoft for a zip file with the logs.

Troubleshooting

Checkout how to troubleshoot failures and collect debug logs: https://docs.microsoft.com/en-us/vsts/build-release/actions/troubleshooting

Error logs

##[debug]Exception:
##[debug]System.ArgumentException: CurrentStorageAccountName is not set. Use Set-AzureSubscription subname -CurrentStorageAccountName storageaccount to set it.
##[debug]   at Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.SetAzureDeploymentCommand.ExecuteCommand() in d:\workspace\powershell-sign\src\ServiceManagement\Compute\Commands.ServiceManagement\HostedServices\SetAzureDeployment.cs:line 217
##[debug]   at System.Management.Automation.CommandProcessor.ProcessRecord()
##[error]CurrentStorageAccountName is not set. Use Set-AzureSubscription subname -CurrentStorageAccountName storageaccount to set it.
##[debug]Processed: ##vso[task.logissue type=error]CurrentStorageAccountName is not set. Use Set-AzureSubscription subname -CurrentStorageAccountName storageaccount to set it.
##[debug]Processed: ##vso[task.complete result=Failed]
gobananasgo commented 4 years ago

+1 My team has also encountered this issue. We migrated many storage accounts to ARM, only to find out that our release pipelines broke.

This fix will have a huge impact on the migration from classic to ARM storage accounts.

arjgupta commented 4 years ago

The task works on the older Azure RDFE model and uses the Azure RDFE cmdlets because Cloud service also works on RDFE (or classic) model and so requires a classic storage account. And not an ARM storage account.