Moved azure subscription from active directory AD1 to active directory AD2. Now tasks start failing as previous ARM endpoint (via Auto SPN) got created with old endpoint details. Hence tasks are not able to generate right access token.
Error Message
The access token is from the wrong issuer 'https://sts.windows.net/***/'. It must match the tenant 'https://sts.windows.net/<TenantIdNew>/' associated with this subscription.
Please use the authority (URL) 'https://login.windows.net/<TenantIdNew>' to get the token.
Note, if the subscription is transferred to another tenant there is no impact to the services, but information about new tenant could take time to propagate (up to an hour). If you just transferred your subscription and see this error message, please try back later. (CODE: 401)
Additional Questions
There are the following possible solutions:
AD1
to AD2
AD1
and AD2
.Answers to additional Questions
How do I find which tenant my VSTS is backing? Where can I find it?
Go AzureDevOps account > Organization > Azure Active Directory
How do I find which tenant my subscription is backed? Where can I find it?
Go to Azure portal > Subscriptions > select your subscription > overview
Is it possible to re-use service endpoints created earlier (with AD1) after the move to AD2?
Yes.
First Let's understand what a service endpoint does internally.
Now let's go through our case,
AD1
, means AD app app1
is being created in active directory AD1
and assigned permission on subscription S
S
to another active directory AD2
, but AD app app1
still resides in previous active directory AD1
.
To re-use existing service endpoint you have to update SPN Id
, SPN key
and tenant Id
in the service endpoint.
In case of manual service connection, it's easy to update via UI but in case of auto SPN flow, you have to update the above mentioned fields via REST API.
Is it possible to update the tenant Id (via REST API) in existing service endpoints after the move to AD2?
Yes.
Get all endpoints
REQUEST TYPE - GET
https://<accountName>.visualstudio.com/<ProjectName>/_apis/distributedtask/serviceendpoints?api-version=3.2-preview.1
Get a specific endpoint
REQUEST TYPE - GET
https://<accountName>.visualstudio.com/<ProjectID>/_apis/distributedtask/serviceendpoints/<SERVICE_ENDPOINT_ID>?api-version=3.2-preview.1
Now update tenant Id
in response and use it as a body in update endpoint REST API.
Update endpoint
REQUEST TYPE - PUT
https://<accountName>.visualstudio.com/<ProjectID>/_apis/distributedtask/serviceendpoints/<SERVICE_ENDPOINT_ID>?api-version=3.2-preview.1
Will MSI based service endpoints be broken or will they be available after move to AD2?
Yes, you only need to update the tenant Id
in service connection.