'Azure Devops - How to reset Resource Group in Edit service connection

In renewing the secret key for a service connection, I accidentally also set Resource group to a specific group, whereas previously it was left blank so it had access to the whole subscription.

I want to revert it back so it has access to the whole subscription, but I cannot seem to clear out the Resource group, it seems like once it's set, it cannot be cleared out.

Short of deleting this service connection and creating a new one with same name, is there some other way to set Resource Group to blank/empty spaces? I could not find any az cli or ps command. I know I could manually grant access to the service principals but then it could be misleading from the UI perspective since it only shows one resource group.

enter image description here



Solution 1:[1]

We can't change the resource group to empty in the UI since it is by design.

There is a workaround to use Rest API to modify the service connection. Please see the similar case: https://developercommunity.visualstudio.com/t/Cant-change-resource-group-to-empty-in-/1396077.

Get Request Body:

GET https://dev.azure.com/{organization}/{project}/_apis/serviceendpoint/endpoints/{endpointId}?api-version=7.1-preview.4

Update Service connection:

PUT https://dev.azure.com/{organization}/_apis/serviceendpoint/endpoints/{endpointId}?api-version=7.1-preview.4

Please set the scope as empty.

"authorization": {
    "parameters": {
        "tenantid": "",
        "serviceprincipalid": "",
        "authenticationType": "spnKey",
        "scope": "",  // this is the resource group
        "serviceprincipalkey": null
    },
    "scheme": "ServicePrincipal"
},

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 unknown