System.NullReferenceException: Object reference not set to an instance of an object

We have a task in our azure PR pipeline to run sonar cloud analysis and the task is falling with the following exception.

20:59:36.848  Creating directory: D:\a\1\.sonarqube\conf
20:59:36.848  Creating directory: D:\a\1\.sonarqube\out
20:59:36.89  **Downloading from https://sonarcloud.io/api/server/version...**
**##[error]20:59:47.622  Failed to request and parse 'https://sonarcloud.io/api/server/version': Object reference not set to an instance of an object.**
##[debug]Processed: ##vso[task.logissue type=error;]20:59:47.622  Failed to request and parse 'https://sonarcloud.io/api/server/version': Object reference not set to an instance of an object.
20:59:47.622  Failed to request and parse 'https://sonarcloud.io/api/server/version': Object reference not set to an instance of an object.
##[debug]Processed: ##vso[task.logissue type=error;]

##[error]Unhandled Exception:
##[debug]Processed: ##vso[task.logissue type=error;]Unhandled Exception:
##[error]System.NullReferenceException: Object reference not set to an instance of an object.
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.<>c__DisplayClass18_0.<<DownloadServerVersion>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.PreProcessor.SonarWebService.<DoLogExceptions>d__17`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.<Execute>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.BootstrapperClass.<PreProcess>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.BootstrapperClass.<Execute>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.Program.<Execute>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.Program.<Execute>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.Program.<Main>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.Program.<Main>(String[] args)
##[debug]Exit code 3762504530 received from tool 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.19.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
##[debug]STDIO streams have closed for tool 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.19.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
##[debug]task result: Failed
##[error]The process 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.19.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 3762504530
##[debug]Processed: ##vso[task.issue type=error;]The process 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.19.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 3762504530
##[debug]Processed: ##vso[task.complete result=Failed;]The process 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.19.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 3762504530
Finishing: Prepare analysis on SonarCloud

Hey @bharatpidapa,

Looking at the log, it looks that there was a failure to call sonarcloud.io from your azure pipeline. Are you sure it is possible to reach sonarcloud.io from the Azure DevOps server? Are you using Azure DevOps self-hosted or cloud version?

Best,
Marcin