0

Using VssConnection (or something else) is there a way to tell if the server being connected to is on premises or an hosted by Microsoft (i.e. Azure DevOps Service)? My research so far says that if the ServerType GUID is {87966eaa-cb2a-443f-be3c-47bd3b5bf3cb} then it is a on-premises instance but I can't find this documented anywhere.

In the previous version of APIs (SOAP based APIs) the ServerCapabilities enum as returned by an instance of TfsTeamProjectCollection used to be able to do this. The property 'IsHostedServer' on TfsTeamProjectCollection had this information which was actually returned from the server itself.

Is there a way to definitely tell this?

Nikhil
  • 3,304
  • 1
  • 25
  • 42
  • 1
    What wrong with check the URL? (if it containd "dev.azure.com" is Azure DevOps Service) – Shayki Abramczyk May 18 '20 at 07:48
  • That is not scaleable. If Azure DevOps allows customized URLs for organizations, this approach will fail. Also the URLs can have a different format i.e. instead of dev.azure.com/org you can also use org.visualstudio.com – Nikhil May 18 '20 at 08:42

1 Answers1

1

Update:

I have tested on my side, you are correct that you can use ServerType property of VssConnection to tell whether the server is hosted or on premises. 87966eaa-cb2a-443f-be3c-47bd3b5bf3cb is server, while 00025394-6065-48ca-87d9-7f5672854ef7 is service. Unfortunately, I don't find any documentation states this information. But from the test, the ServerType does give the server information.


Usually, we use the following code to connect to Azure DevOps Service/Server:

VssConnection connection = new VssConnection(new Uri(c_collectionUri), creds);

If you connect to Azure DevOps Service, you would define the c_collectionUri as below:

String c_collectionUri = "https://dev.azure.com/org";

And if you connect to Azure DevOps Server, you would define the c_collectionUri as below:

String c_collectionUri = "http://TFS:8080/tfs/defaultcollection";
Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • Thanks but that is quite error prone and not scaleable. If Azure DevOps allows customized URLs for organizations, this approach will fail. Also the URLs can have a different format i.e. instead of dev.azure.com/org you can also use org.visualstudio.com. Finally there is no compulsion on hosted servers to use port 8080. – Nikhil May 18 '20 at 08:42
  • For Azure DevOps Service, you would only have two formats of the URL: https://learn.microsoft.com/en-us/azure/devops/release-notes/2018/sep-10-azure-devops-launch#administration. For Azure DevOps Server, you have to specify the team project collection. It's supposed to distinguish the service and server easily. – Cece Dong - MSFT May 18 '20 at 08:50
  • I have added more details on how this information could be ascertained in the SOAP based APIs available up until v15.0 of Microsoft.TeamFoundation.Client package. I am looking for a more concrete and longer term option than relying on URL structure.s – Nikhil May 18 '20 at 14:05
  • Thanks for your explanation. I now understand your question better. I have tested on my side, you are correct that you can use `ServerType` property in `VssConnection` to tell whether the server is hosted or on premises. `87966eaa-cb2a-443f-be3c-47bd3b5bf3cb` is server, while `00025394-6065-48ca-87d9-7f5672854ef7` is service. – Cece Dong - MSFT May 19 '20 at 08:31
  • Thanks Cece. Is this documented anywhere that you might know of? – Nikhil May 20 '20 at 06:09