Azure文件复制任务-[错误]对象引用未设置为对象的实例

时间:2020-02-03 22:44:41

标签: azure azure-devops azure-storage-blobs

在Azure DevOps中,我有一个发布管道,该管道使用Azure文件copy @版本2.154.19将某些文件复制到blob存储。

最近,任务开始失败,并在日志中出现以下错误:

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

Azure DevOps的完整任务日志如下

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

任务的配置如下: enter image description here

最近什么都没有改变,但是此任务现在似乎失败了。

我将变量system.debug设置为true,现在我得到以下日志:

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

是否可以为Azure DevOps任务启用更好的调试?

1 个答案:

答案 0 :(得分:1)

嗨,凯文(Kevin),如果要在版本定义中获取调试信息,请创建一个变量system.debug并将其设置为true。我只是看了RFC3447,发现该任务的v2版本有一个相同的错误消息出现。

我将通过调试运行它,以查看是否存在相同的问题,然后尝试该任务的v3版本。