WaelHamze / dyn365-ce-vsts-tasks

VSTS Extension for Dynamics 365 Customer Engagement
https://marketplace.visualstudio.com/items?itemName=WaelHamze.xrm-ci-framework-build-tasks
GNU General Public License v3.0
115 stars 54 forks source link

"Unable to deserialize the response." when backup online instance #222

Open epellegrom opened 3 years ago

epellegrom commented 3 years ago

Hi,

For a couple of days, we experience an error when we execute the task: "MSCRM Backup Online Instance". We get the error: ##[error]Unable to deserialize the response.

Starting: Backup instance
==============================================================================
Task         : MSCRM Backup Online Instance
Description  : Creates a backup of a Dynamics 365 Customer Engagement Online Instance
Version      : 10.0.6
Author       : Wael Hamze
Help         : This task uses the Microsoft.Xrm.OnlineManagementAPI: https://www.powershellgallery.com/packages/Microsoft.Xrm.OnlineManagementAPI
==============================================================================
##[error]Unable to deserialize the response.
Finishing: Backup instance

This task is using the: https://www.powershellgallery.com/packages/Microsoft.Xrm.OnlineManagementAPI what I notice is that this library is also updated a couple of days ago, maybe it is related?

Many thanks already!

Regards, Erik

WaelHamze commented 3 years ago

@epellegrom

You can change the version of the OnlineManagementAPI to the latest version in the tool installer task and see if it will work?

bpevans commented 3 years ago

@waelhamze - significant changes to the OnlineManagementAPI nuget package have been made in preperation for legacy service decom. A couple of things that are relevant:

WaelHamze commented 3 years ago

@bpevans I am aware of these changes.

Have you tried using the latest version of the OnlineManagement API in the tool installer task? This should still work while we change the implementation to use the latest APIs.

wfemichel commented 3 years ago

I have also been unable to get "MSCRM Backup Online Instance" to work recently. I am getting a different error "Object reference not set to an instance of an object". I have tried using the latest version, but get the same error.

mVermaat commented 3 years ago

I have the same issue as @wfemichel. Seems to be some sort of authentication issue. Not really sure what is causing this. I actually downloaded you ps1 scripts directly and called it locally. I got the same error. I'm sure the username and password are correct. They are directly copied from a password manager app and they work when logging into 'https://admin.powerplatform.microsoft.com'

2021-01-18T14:39:48.0185687Z ##[debug]Imported Online Management Module 2021-01-18T14:39:48.0799523Z ##[debug]Entering OnlineInstanceFunctions.ps1 2021-01-18T14:39:48.0827893Z ##[debug]Leaving OnlineInstanceFunctions.ps1 2021-01-18T14:39:48.0993209Z ##[debug]Connecting to API server: https://admin.services.crm4.dynamics.com/ 2021-01-18T14:39:48.1622660Z ##[debug]Entering GetCrmInstances - ProcessRecord 2021-01-18T14:39:48.1697420Z ##[debug]Executing GetCrmInstances 2021-01-18T14:39:48.2319227Z ##[debug]Requesting Authentication - Start 2021-01-18T14:39:48.2367921Z ##[debug]Requesting Authority From server - Start 2021-01-18T14:39:48.3158481Z ##[debug]Failed GetCrmInstances - ProcessRecord : 00:00:00.1499129 2021-01-18T14:39:48.3192613Z ##[debug] 2021-01-18T14:39:48.3435229Z ##[debug]Message: The pipeline has been stopped. 2021-01-18T14:39:48.3488340Z ##[debug]Source : System.Management.Automation 2021-01-18T14:39:48.3517806Z ##[debug]Method : _WriteErrorSkipAllowCheck 2021-01-18T14:39:48.3548318Z ##[debug]Date : 1/18/2021 2021-01-18T14:39:48.3602227Z ##[debug]Time : 2:39:48 PM 2021-01-18T14:39:48.3688102Z ##[debug]Error : The pipeline has been stopped. 2021-01-18T14:39:48.3720284Z ##[debug]Stack Trace : at System.Management.Automation.MshCommandRuntime._WriteErrorSkipAllowCheck(ErrorRecord errorRecord, Nullable1 actionPreference) 2021-01-18T14:39:48.3750066Z ##[debug] at System.Management.Automation.MshCommandRuntime.DoWriteError(Object obj) 2021-01-18T14:39:48.3778951Z ##[debug] at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state) 2021-01-18T14:39:48.3812239Z ##[debug] at System.Management.Automation.MshCommandRuntime.WriteError(ErrorRecord errorRecord, Boolean overrideInquire) 2021-01-18T14:39:48.3849265Z ##[debug] at System.Management.Automation.Cmdlet.WriteError(ErrorRecord errorRecord) 2021-01-18T14:39:48.3898581Z ##[debug] at Microsoft.Xrm.OnlineManagementAPI.Auth.AuthManager.ExecuteAuthenticateServiceProcess(PSCredential clientCredentials, X509Certificate2 userCert, UserIdentifier user, PromptBehavior promptBehavior, String tokenCachePath, Nullable1 TenantId) 2021-01-18T14:39:48.3929110Z ##[debug] at Microsoft.Xrm.OnlineManagementAPI.Auth.AuthManager.d20.MoveNext() 2021-01-18T14:39:48.3956021Z ##[debug]--- End of stack trace from previous location where exception was thrown --- 2021-01-18T14:39:48.4014778Z ##[debug] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 2021-01-18T14:39:48.4072166Z ##[debug] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 2021-01-18T14:39:48.4100853Z ##[debug] at Microsoft.Xrm.OnlineManagementAPI.Auth.AuthManager.d29.MoveNext() 2021-01-18T14:39:48.4162658Z ##[debug]--- End of stack trace from previous location where exception was thrown --- 2021-01-18T14:39:48.4195134Z ##[debug] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 2021-01-18T14:39:48.4247895Z ##[debug] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 2021-01-18T14:39:48.4275444Z ##[debug] at Microsoft.Rest.TokenCredentials.d17.MoveNext() 2021-01-18T14:39:48.4329437Z ##[debug]--- End of stack trace from previous location where exception was thrown --- 2021-01-18T14:39:48.4346951Z ##[debug] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 2021-01-18T14:39:48.4373641Z ##[debug] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 2021-01-18T14:39:48.4401173Z ##[debug] at Microsoft.Xrm.Services.Admin.Client.D365CEAdminClient.d32.MoveNext() 2021-01-18T14:39:48.4512434Z ##[debug]--- End of stack trace from previous location where exception was thrown --- 2021-01-18T14:39:48.4574771Z ##[debug] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 2021-01-18T14:39:48.4598116Z ##[debug] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 2021-01-18T14:39:48.4630248Z ##[debug] at Microsoft.Xrm.Services.Admin.Client.D365CEAdminClientExtensions.d__11.MoveNext() 2021-01-18T14:39:48.4662182Z ##[debug]--- End of stack trace from previous location where exception was thrown --- 2021-01-18T14:39:48.4692388Z ##[debug] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 2021-01-18T14:39:48.4723926Z ##[debug] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 2021-01-18T14:39:48.4753416Z ##[debug] at Microsoft.Xrm.Services.Admin.Client.D365CEAdminClientExtensions.GetInstances(ID365CEAdminClient operations) 2021-01-18T14:39:48.4823995Z ##[debug] at Microsoft.Xrm.OnlineManagementAPI.GetCrmInstances.ProcessRecord() 2021-01-18T14:39:48.4851741Z ##[debug]====================================================================================================================== 2021-01-18T14:39:48.4878679Z ##[debug] 2021-01-18T14:39:48.5162148Z ##[debug]Caught exception from task script. 2021-01-18T14:39:48.5226124Z ##[debug]Error record: 2021-01-18T14:39:48.6450335Z ##[debug]Get-CrmInstances : Object reference not set to an instance of an object. 2021-01-18T14:39:48.6491175Z ##[debug]At C:\hostedtoolcache\windows\MSCRMBuildTools\12.0.37\xRMCIFramework\9.0.0\OnlineInstanceFunctions.ps1:14 char:15 2021-01-18T14:39:48.6519215Z ##[debug]+ $instances = Get-CrmInstances -ApiUrl $ApiUrl -Credential $Cred 2021-01-18T14:39:48.6550357Z ##[debug]+ ~~~~~~~~~~ 2021-01-18T14:39:48.6621907Z ##[debug] + CategoryInfo : PermissionDenied: (:) [Get-CrmInstances], NullReferenceException 2021-01-18T14:39:48.6652686Z ##[debug] + FullyQualifiedErrorId : ERROR REQUESTING Token FROM THE Authentication context,Microsoft.Xrm.OnlineManagementAPI .GetCrmInstances 2021-01-18T14:39:48.6695327Z ##[debug] 2021-01-18T14:39:48.6817463Z ##[debug]Script stack trace: 2021-01-18T14:39:48.6932543Z ##[debug]at Get-XrmInstanceByName, C:\hostedtoolcache\windows\MSCRMBuildTools\12.0.37\xRMCIFramework\9.0.0\OnlineInstanceFunctions.ps1: line 14 2021-01-18T14:39:48.6965825Z ##[debug]at , C:\hostedtoolcache\windows\MSCRMBuildTools\12.0.37\xRMCIFramework\9.0.0\BackupOnlineInstance.ps1: line 60 2021-01-18T14:39:48.7036573Z ##[debug]at , D:\a_tasks\MSCRMBackupOnlineInstance_0c3e661c-d316-443e-9a77-470989da8e29\12.0.5\MSCRMBackupOnlineInstance.ps1: line 38 2021-01-18T14:39:48.7071491Z ##[debug]at , : line 1 2021-01-18T14:39:48.7109423Z ##[debug]at , : line 22 2021-01-18T14:39:48.7142864Z ##[debug]at , : line 18 2021-01-18T14:39:48.7171229Z ##[debug]at , : line 1 2021-01-18T14:39:48.7209176Z ##[debug]Exception: 2021-01-18T14:39:48.7285081Z ##[debug]System.NullReferenceException: Object reference not set to an instance of an object. 2021-01-18T14:39:48.7358847Z ##[debug] at Microsoft.Xrm.OnlineManagementAPI.Auth.AuthManager.GetAuthorityFromTargetService(String targetServiceUrl) 2021-01-18T14:39:48.7393167Z ##[debug] at Microsoft.Xrm.OnlineManagementAPI.Auth.AuthManager.ExecuteAuthenticateServiceProcess(PSCredential clientCredentials, X509Certificate2 userCert, UserIdentifier user, PromptBehavior promptBehavior, String tokenCachePath, Nullable`1 TenantId) 2021-01-18T14:39:48.7844695Z ##[error]Object reference not set to an instance of an object. 2021-01-18T14:39:48.8223576Z ##[debug]Processed: ##vso[task.logissue type=error]Object reference not set to an instance of an object. 2021-01-18T14:39:48.8225313Z ##[debug]Processed: ##vso[task.complete result=Failed] 2021-01-18T14:39:48.8539909Z ##[section]Finishing: Backup instance

bpevans commented 3 years ago

The nuget packages being used in this system were recently updated. The public surface to that nuget package is the PowerShell cmdlets. In previous versions of the cmdlets they were dependent on the DLLs shipped in the nuget. All the cmdlets have been updated to rely on another mechanism as well as redirecting all calls to other power platform endpoints. However the legacy DLLs are still shipped in the nuget and are completely non-functional. This package needs to be re-written to not have dependencies on the DLLs shipped in the OnlineManagementAPI nuget since they no longer work.