1
votes

Within Azure DevOps I have a release pipeline that uses the Azure file copy @ version 2.154.19 to copy some files to blob storage.

Recently, the task started to fail with the following error in the logs:

2020-02-03T11:15:33.0304141Z ##[error]Object reference not set to an instance of an object.

The full task logs from Azure DevOps are as follows

2020-02-03T11:15:14.5316566Z ##[section]Starting: AzureBlob File Copy
2020-02-03T11:15:14.5429010Z ==============================================================================
2020-02-03T11:15:14.5429097Z Task         : Azure file copy
2020-02-03T11:15:14.5429168Z Description  : Copy files to Azure Blob Storage or virtual machines
2020-02-03T11:15:14.5429219Z Version      : 2.154.19
2020-02-03T11:15:14.5429281Z Author       : Microsoft Corporation
2020-02-03T11:15:14.5429338Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-file-copy
2020-02-03T11:15:14.5429551Z ==============================================================================
2020-02-03T11:15:17.6071596Z ##[command]Import-Module -Name C:\Modules\azurerm_2.1.0\AzureRM\2.1.0\AzureRM.psd1 -Global
2020-02-03T11:15:29.5994320Z ##[warning]The names of some imported commands from the module 'AzureRM.Websites' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
2020-02-03T11:15:29.6177486Z ##[command]Import-Module -Name C:\Modules\azurerm_2.1.0\AzureRM.Profile\2.1.0\AzureRM.Profile.psm1 -Global
2020-02-03T11:15:30.0756632Z ##[command]Add-AzureRMAccount -ServicePrincipal -Tenant *** -Credential System.Management.Automation.PSCredential -EnvironmentName AzureCloud @processScope
2020-02-03T11:15:31.2123104Z ##[command] Select-AzureRMSubscription -SubscriptionId 4fc034ca-6877-4bfd-83a6-5ffe29608da5 -TenantId ***
2020-02-03T11:15:33.0304141Z ##[error]Object reference not set to an instance of an object.
2020-02-03T11:15:33.0638228Z ##[section]Finishing: AzureBlob File Copy

The configuration for the task is as follows: enter image description here

Nothing has changed recently but this task now seems to be failing.

I've set the variable system.debug to true and now I get the following logs:

2020-02-04T13:12:06.4274088Z ##[debug]Validating minimum required azure powershell version is greater than or equal to 0.9.0
2020-02-04T13:12:06.4332040Z ##[debug]Populating RepositorySourceLocation property for module AzureRM.
2020-02-04T13:12:06.4360442Z ##[debug]Loading module from path 'C:\Modules\azurerm_2.1.0\AzureRM\2.1.0\AzureRM.psm1'.
2020-02-04T13:12:06.4556756Z ##[debug]Installed Azure PowerShell version: 2.1.0
2020-02-04T13:12:06.4579801Z ##[debug]Compare azure versions: 2.1.0, 0.9.0
2020-02-04T13:12:06.4599735Z ##[debug]Validated the required azure powershell version is greater than or equal to 0.9.0
2020-02-04T13:12:06.4685961Z ##[debug][Azure Call]Getting resource details for azure storage account resource: xxx221 with resource type: Microsoft.Storage/storageAccounts
2020-02-04T13:12:07.0852040Z ##[debug]System.NullReferenceException: Object reference not set to an instance of an object.
2020-02-04T13:12:07.0865383Z ##[debug]   at Microsoft.Azure.Commands.Management.Storage.Models.PSStorageAccount..ctor(StorageAccount storageAccount) in d:\workspace\powershell-sign\src\ResourceManager\Storage\Commands.Management.Storage\Models\PSStorageAccount.cs:line 27
2020-02-04T13:12:07.0880480Z ##[debug]   at Microsoft.Azure.Commands.Management.Storage.Models.PSStorageAccount.Create(StorageAccount storageAccount, IStorageManagementClient client) in d:\workspace\powershell-sign\src\ResourceManager\Storage\Commands.Management.Storage\Models\PSStorageAccount.cs:line 87
2020-02-04T13:12:07.0894045Z ##[debug]   at Microsoft.Azure.Commands.Management.Storage.StorageAccountBaseCmdlet.<>c__DisplayClass2.<WriteStorageAccountList>b__1(StorageAccount storageAccount) in d:\workspace\powershell-sign\src\ResourceManager\Storage\Commands.Management.Storage\StorageAccount\StorageAccountBaseCmdlet.cs:line 161
2020-02-04T13:12:07.0908039Z ##[debug]   at Microsoft.WindowsAzure.Commands.Utilities.Common.GeneralUtilities.ForEach[T](IEnumerable`1 sequence, Action`1 action) in d:\workspace\powershell-sign\src\Common\Commands.Common\GeneralUtilities.cs:line 147
2020-02-04T13:12:07.0923496Z ##[debug]   at Microsoft.Azure.Commands.Management.Storage.StorageAccountBaseCmdlet.WriteStorageAccountList(IEnumerable`1 storageAccounts) in d:\workspace\powershell-sign\src\ResourceManager\Storage\Commands.Management.Storage\StorageAccount\StorageAccountBaseCmdlet.cs:line 161
2020-02-04T13:12:07.0938702Z ##[debug]   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord() in d:\workspace\powershell-sign\src\Common\Commands.Common\AzurePSCmdlet.cs:line 610
2020-02-04T13:12:07.1882171Z ##[debug]Processed: ##vso[task.logissue type=error;code={"Task_Internal_Error":"TemporaryCopyingToBlobContainerFailed"};]
2020-02-04T13:12:07.1928893Z ##[debug]Trying to disconnect from Azure and clear context at process scope
2020-02-04T13:12:07.4018399Z ##[debug]Caught exception from task script.
2020-02-04T13:12:07.4054453Z ##[debug]Error record:
2020-02-04T13:12:07.4764182Z ##[debug]Get-AzureRmStorageAccount : Object reference not set to an instance of an object.
2020-02-04T13:12:07.4779906Z ##[debug]At D:\a\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\2.154.19\AzureUtilityGTE1.0.ps1:27 char:47
2020-02-04T13:12:07.4795063Z ##[debug]+ ... ResourceDetails = Get-AzureRmStorageAccount -ErrorAction Stop | Where ...
2020-02-04T13:12:07.4809226Z ##[debug]+                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-02-04T13:12:07.4822827Z ##[debug]    + CategoryInfo          : CloseError: (:) [Get-AzureRmStorageAccount], NullReferenceException
2020-02-04T13:12:07.4836831Z ##[debug]    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Management.Storage.GetAzureStorageAccountCommand
2020-02-04T13:12:07.4851249Z ##[debug] 
2020-02-04T13:12:07.4876156Z ##[debug]Script stack trace:
2020-02-04T13:12:07.4914114Z ##[debug]at Get-AzureStorageAccountResourceGroupName, D:\a\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\2.154.19\AzureUtilityGTE1.0.ps1: line 27
2020-02-04T13:12:07.4926798Z ##[debug]at Get-AzureStorageKeyFromARM, D:\a\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\2.154.19\AzureUtilityRest.ps1: line 28
2020-02-04T13:12:07.4942375Z ##[debug]at Get-StorageKey, D:\a\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\2.154.19\Utility.ps1: line 149
2020-02-04T13:12:07.4955473Z ##[debug]at <ScriptBlock>, D:\a\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\2.154.19\AzureFileCopy.ps1: line 101
2020-02-04T13:12:07.4968797Z ##[debug]at <ScriptBlock>, <No file>: line 1
2020-02-04T13:12:07.4982585Z ##[debug]at <ScriptBlock>, <No file>: line 22
2020-02-04T13:12:07.4996709Z ##[debug]at <ScriptBlock>, <No file>: line 18
2020-02-04T13:12:07.5010393Z ##[debug]at <ScriptBlock>, <No file>: line 1
2020-02-04T13:12:07.5033417Z ##[debug]Exception:
2020-02-04T13:12:07.5059409Z ##[debug]System.NullReferenceException: Object reference not set to an instance of an object.
2020-02-04T13:12:07.5073947Z ##[debug]   at Microsoft.Azure.Commands.Management.Storage.Models.PSStorageAccount..ctor(StorageAccount storageAccount) in d:\workspace\powershell-sign\src\ResourceManager\Storage\Commands.Management.Storage\Models\PSStorageAccount.cs:line 27
2020-02-04T13:12:07.5086710Z ##[debug]   at Microsoft.Azure.Commands.Management.Storage.Models.PSStorageAccount.Create(StorageAccount storageAccount, IStorageManagementClient client) in d:\workspace\powershell-sign\src\ResourceManager\Storage\Commands.Management.Storage\Models\PSStorageAccount.cs:line 87
2020-02-04T13:12:07.5104212Z ##[debug]   at Microsoft.Azure.Commands.Management.Storage.StorageAccountBaseCmdlet.<>c__DisplayClass2.<WriteStorageAccountList>b__1(StorageAccount storageAccount) in d:\workspace\powershell-sign\src\ResourceManager\Storage\Commands.Management.Storage\StorageAccount\StorageAccountBaseCmdlet.cs:line 161
2020-02-04T13:12:07.5119770Z ##[debug]   at Microsoft.WindowsAzure.Commands.Utilities.Common.GeneralUtilities.ForEach[T](IEnumerable`1 sequence, Action`1 action) in d:\workspace\powershell-sign\src\Common\Commands.Common\GeneralUtilities.cs:line 147
2020-02-04T13:12:07.5133721Z ##[debug]   at Microsoft.Azure.Commands.Management.Storage.StorageAccountBaseCmdlet.WriteStorageAccountList(IEnumerable`1 storageAccounts) in d:\workspace\powershell-sign\src\ResourceManager\Storage\Commands.Management.Storage\StorageAccount\StorageAccountBaseCmdlet.cs:line 161
2020-02-04T13:12:07.5148324Z ##[debug]   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord() in d:\workspace\powershell-sign\src\Common\Commands.Common\AzurePSCmdlet.cs:line 610
2020-02-04T13:12:07.5213129Z ##[error]Object reference not set to an instance of an object.
2020-02-04T13:12:07.5213434Z ##[debug]Processed: ##vso[task.logissue type=error]Object reference not set to an instance of an object.
2020-02-04T13:12:07.5222027Z ##[debug]Processed: ##vso[task.complete result=Failed]
2020-02-04T13:12:07.5808798Z ##[section]Finishing: AzureBlob File Copy

Is there any better debugging that I can enable for Azure DevOps tasks?

1
Tested and cannot reproduce the issue, just encounter the issue github.com/microsoft/azure-pipelines-tasks/issues/9922, but can copy files to blob storage successfully. Whatever, please try the preview version (3.*) and check if that works, both of them are working for me.Andy Li-MSFT
Just tried the preview version (3.x) and that fails in the same way. I also tried the 1.x version but that won't work use to validation issues on the container name containing $.Kevin Smith
Tested again but still cannot reproduce the issue. Please try to create a new storage account and try it again to check if that works.Andy Li-MSFT
@AndyLi-MSFT just created another storage account and tried to copy to that one instead and it gets the same error.Kevin Smith
Well, whatever this issue is reported in Github : github.com/microsoft/azure-pipelines-tasks/issues/12154, let's waiting for the product team's response.Andy Li-MSFT

1 Answers

1
votes

Hey Kevin if you want to get debug information in a release definition create a variable system.debug and set it to true. I just took a look at github and there is an open issue with the same error message for the v2 version of the task.

I would run it with debug, to see if its the same issue and then try the v3 version of the task.