How to get the Azure DevOps Service Principal ID + Name - azure

Perhaps my brain is still in bed, but I cannot figure out how to get the name and ID of my Azure DevOps Service Principal. I need to give it permission on a Synapse workspace.
Do I have to create a Azure DevOps Service Principal or is it created automatically once I created a project (and repositories) in Azure DevOps?

As described above you should create a service connection that will automatically create an application (service principal) on which you can assign IAM privileges.
In order to find the application name/ID you should go under your service connection and press Manage Service Principal. Then azure devops will redirect you on Azure on App Registrations/App

Do I have to create a Azure DevOps Service Principal or is it created automatically once I created a project (and repositories) in Azure DevOps?
You need to create service principal manually. Here are the detailed steps:
Go to "Project Settings" -> "Pipelines/Service connections".
Click on "Create a service connection". Choose "Azure resource manager". Scroll down and click on "Next".
Select "Service principal (automatic)" (You can select the manual one if you want to manually enter information such as subscription ID and credential). Click on "Next".
Select "Subscription" as scope level. If it shows that you do not have an active subscription, please try to do this in InPrivate window. Then fill in the information about service connection name. Click on "Save".

Related

Azure CI/CD pipeline and Azure portal subscription problem

I have one problem with my Azure. I created build pipeline, and now i want to set up relase pipeline. I choosen Deploy App service, where is located my app service with subsription and resource group..
In Azure subsription dropdown I choose my subsription, it is listed.. but I need to authorize myself. I click then on Authorize and I get this error..
Error(s):
Service connection creation operation failed
Error: Service connection with name Microsoft Partner Network (subscription number) already exists. Only a user having Administrator/User role permissions on service connection Microsoft Partner Network (subsription number ) can see it.
I guess it is problem with authorisation, but I cant figure what is problem. I have privileges for my resource group.
The error indicates that within Azure DevOps a service connection with the name 'Microsoft Partner Network' already exists and that you do not have permissions to update/edit it. The permissions are actually needed within the Azure DevOps Project or Organization and are separate from Azure Resource Manager RBAC permissions such as are assigned to resource groups.
See Service Connection security roles for the requires role and references to managing project roles in Azure DevOps

Owned Azure Subscription not showing in Azure DevOps Pipeline

I am trying to setup an CICD from our Azure Devops to the Azure Subscription owned by our Client.
But the subscription is not appearing in the list of Azure Subscriptions even if I already have Owner level of role:
My CICD Subscription List Available:
The Subscription where I want to deploy:
My current role to our Client Active Directory:
Also note that I am a Member of their Active Directory not just a Guest.
I also checked this article but no luck:
https://learn.microsoft.com/en-us/azure/devops/pipelines/release/azure-rm-endpoint?view=azure-devops#the-user-has-only-guest-permission-in-the-directory
The problem is not with the roles and permissions, for some reason AAD with MFA enables somehow prevents smooth integration with Azure DevOps, on my case i disabled deleted my MFA options then tried to add the subscription again via Azure Pipeline.
Some subscriptions are missing from the list of subscriptions:
To fix this issue you will need to modify the supported account types and who can use your application. To do so, follow the steps below:
Sign in to the Azure portal.
If you have access to multiple tenants, use the Directory + subscription filter in the top menu to select the tenant in which you want to register an application.
Search for and select Azure Active Directory.
Under Manage, select App registrations.
Select you application from the list of registered applications.
Under Essentials, select Supported account types.
Under Supported account types, Who can use this application or access this API? select Accounts in any organizational directory.
Select Save.

I Dont see AKS from DevOps - Service Connection

Im not seeing AKS from DevOps. Im trying to create a pipeline but AKS is not showing.
First of all, I created a service connection --> Azure Resource Manager --> Service Principal (Manual)
I have been working this way and I see all my AKS. I have a problem with this new one.
error
I dont know where is the problem. In DevOps I can see all my AKS except this new one
Any ideas to check?
In your Azure DevOps project navigate to Project Settings > Service Connections and select your Service Connection to Azure which will look something like this:
Depending on how your Service Principal was set up you may be able to browse to it directly in the Azure Portal by clicking the Manage Service Principal link. There are other ways to set up a Service Connection and the method to find the Service Principal in the Azure Portal will differ, checkout the documentation here. Make a note of the Display Name for your Service Principal.
In the Azure Portal navigate to your AKS resource then navigate to the Access Control (IAM) blade and click Role Assignments. Check what Roles the Azure AD Service Principal for your Azure DevOps Service Connection has been assigned, it will need at least Contributor to make changes to your AKS cluster.
You can use the verify connection link on the Edit service connection page to verify your connection information and check whether the Grant access permission to all pipelines option is checked.
In addition,here is a document on Troubleshoot Azure Resource Manager service connections you can refer to.

Using Managed Identity in Azure Pipelines: GetUserAccessToken: Failed to obtain an access token of identity. AAD returned silent failure

I am trying to run an Azure Resource Group Deployment task in Azure Pipelines. I have deployed an Azure Pipelines self-hosted agent on an Azure VM running Windows, and in my Azure DevOps organization I have set up an Azure Resource Manager service connection to a VM with a managed service identity.
However, I get the following error when trying to configure my Azure Resource Group Deployment task with my service connection with managed identity:
GetUserAccessToken: Failed to obtain an access token of identity . AAD returned silent failure.
Screenshot:
I have already verified that I granted access (Contributor) to the VM's managed identity to the target resource group:
The service connection is also scoped to the Azure subscription:
Any help on diagnosing this issue is appreciated. Thanks!
Failed to obtain an access token typically occur when your session has expired.
To resolve these issues:
Sign out of Azure Pipelines or TFS.
Open an InPrivate or incognito browser window and navigate to https://visualstudio.microsoft.com/team-services/.
If you are prompted to sign out, do so.
Sign in using the appropriate credentials.
Choose the organization you want to use from the list.
Select the project you want to add the service connection to.
Create the service connection you need by opening the Settings page. Then, select Services > New service connection > Azure Resource Manager.
Refer to:
https://learn.microsoft.com/en-us/azure/devops/pipelines/release/azure-rm-endpoint?view=azure-devops#sessionexpired
In case this is useful to anyone else, I had a similar issue when modifying service connections through Azure DevOps. The solution provided by Charlie Brown pointed me in the right direction: The user in AAD isn't automatically added to the Azure DevOps Enterprise Application, so if you run into this it may mean that you need to add the user or group that's trying to access it through DevOps.
In my case I just added myself as and owner and user through the Azure Portal -> Azure Active Directory -> Enterprise Applications -> Azure DevOps.
I didn't have to create another user, nor modify anything with MFA.
It appears that the issue comes about because it is the user account authenticated to Azure DevOps that is retrieving subscription information. Azure DevOps is not using the managed identity to retrieve the subscription information.
In particular, my original Azure DevOps user account had MFA turned on to authenticate to an Azure subscription (e.g. portal.azure.com), but did not have MFA turned on to authenticate to Azure DevOps (e.g. dev.azure.com/). I think that this was causing the issue when failing to get an access token:
I created a different user account in my Azure AD, gave it access to my Azure DevOps organization, and made sure that this new user account had Reader permissions over the target subscription and did not have MFA turned on. This resolved the issue of getting subscription info when using managed identity:
My scenario getting this error was adding a Service Connection to a Management Group in Azure DevOps
GetUserAccessToken: Failed to obtain an access token of identity
{{GUID}}. AAD returned silent failure.
Fix for me was adding my account as a Project Collection Admin in DevOps... details below:
Tried every permission possible ... GA, ROOT Mgmt Group Owner (via AAD setting), target Mgmt Group Owner, Subscription Owner, App Administrator... In devops i am a project admin and i have Admin security role in service connections.
Interesting diff i have here, my Azure AD home tenant is different from my Azure Subscription AD tenant (i am a B2B Guest).
I actually tried to use a different DevOps tenant that has an AAD tied to the Azure Subscription tenant and it WORKED :( This lead me to diving further into what is different. Aside from the DevOps->AAD link, I am also COLLECTION admin on the working one, and only a project admin on the failing one. I made sure I had Management Group Owner rights and then added my account as a Project Collection Admin - WORKED!
Ref: https://developercommunity.visualstudio.com/solutions/1246044/view.html

Auhtorizing Azure subscription in VSTS fails

I'm trying to add a release to VSTS. Our VSTS is backed by Azure AD and I have logged in with the account that is the admin of the Azure subscription to which I want to deploy the release. I can see the Azure subscription in the dropdown but when I click Authorize I get the following error popup.
The reason is that the authentication pop-up window has been blocked, turn pop-up blocker off or change another browser and try again.
Change security and privacy settings for Internet Explorer 11
On the other hand, you also can manual configure the azure service endpoint, refer to this article below (manual configuration section)
Automating Azure Resource Group deployment using a Service Principal in Visual Studio Online: Build/Release Management

Resources