Azure Devops - New service connection - ACR - No registries found - azure

I am the Co-Administrator (Owner) of the Azure subscription. When i try to create new service connection in the azure devops to the Azure continer resitry, I am reciving following error
"No registries found"

Issue resolved. Some unknown issue from azure. My colleague created repository now he is no longer with us. I could not able to see that repository eventhough i have all permissions in azure and azure devops.
I did trail and error.
Disabling and re enabling Admin user in ACR fixed the issue.

Related

No option to use managed identity in azure devops to connecti with container registry

I'd like to create connection between pipeline in Azure devops and container registry.
Admins created Managed identity for me. I'd like to use that one but there is no way.
According to guide: https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/containers/publish-to-acr?view=azure-devops&tabs=javascript%2Cportal%2Cmsi&fbclid=IwAR2bV28HzRs8v-qTXuo592KU5KxOFnNsOvhxpNx0ZCBYfz2OPnYXWh7rqUs
I should be able to create connection with Authentication type: Managed Service Identity like on below screen:
In my case there is no way so select this option. I can only select Service Principial in Authentication type :
That's not what I want. Why is that? Is it related to lack of some permission? Is it maybe forbidden to connect via azure managed identity in the newest azure devops version?. I would be grateful for the answer.
I tried to reproduce your scenario in my environment and got below results:-
When I tried to Create a Service Connection with docker registry even I did not receive any option to Select Managed Service Identity refer below:-
I went to my Project settings and tried creating a service connection with Azure DevOps Managed Identity like below:-
Alternatively:-
You can create Managed Service Identity separately in Azure DevOps by selecting azure Resource Management tab like below:-
Create a managed Identity for your resource
Set Azure role assignments to the managed identity
Create Service connection for that managed identity like above
Include the service connection in the pipeline like below:-
- task: AzureCLI#2
inputs:
azureSubscription: 'acr12325'
Reference:-
Service connections in Azure Pipelines - Azure Pipelines | Microsoft Learn

Azure CLI not found in Jenkins

I have install azure cli plugins in jenkins after that i setup Azure Service Principal and got Successfully verified the Microsoft Azure Service Principal after that i create a new job and added az version to check az is installed or not in it and got failed error below is the screenshot of that error
Note:- My Jenkins is having v2.332.1 and installed in AKS Cluster as a Helm chat my jenkins is running
Here is the screenshot of plugin installed
Here is the my job new create in freestylejob
Please help out with this issue
You need to install azure cli in the Jenkins Host as well.
from
https://plugins.jenkins.io/azure-cli/ - Prerequisites
To use this plugin, first you need to have an Azure Service Principal
in your Jenkins instance.
1.Create an Azure Service Principal through Azure CLI or Azure portal.
2.Open Jenkins dashboard, go to Credentials, add a new Microsoft Azure Service Principal with the credential information you just created.
3.Install Azure CLI in the Jenkins Host
from your description, I can see you have 1,2 steps completed and possibly 3 is missing.

Azure DevOps Pipeline - Pushing to Azure Container Registry - Permission error

I have created an Azure Container Registry.
I have an Azure DevOps project.
I have created an Azure DevOps Pipeline using the wizard so
that it uses the standard template to build and push a Docker image.
When validating the Pipeline the following error is thrown:
Failed to set Azure permission 'RoleAssignmentId: ****' for the service principal '****' on subscription ID '****': error code: Forbidden, inner error code: AuthorizationFailed, inner error message The client '****' with object id '****' does not have authorization to perform action 'Microsoft.Authorization/roleAssignments/write' over scope '/subscriptions/****/resourceGroups/****/providers/Microsoft.ContainerRegistry/registries/****/providers/Microsoft.Authorization/roleAssignments/****' or the scope is invalid. If access was recently granted, please refresh your credentials. Ensure that the user has 'Owner' or 'User Access Administrator' permissions on the Subscription.
What configuration could I be missing? The documentation for this is all very sparse and written as though it should all just work.
Thanks
You need to add AcrPull permission to service principal you used here. Please got to you ACR and add it.
Here you have id of you service principal:
Failed to set Azure permission 'RoleAssignmentId: ' for the service principal ''
Also please check also networking on ACR if it blocks you or not.
To build and push your Docker image in Azure pipeline, you need follow the steps below:
Navigate to Project Settings > Service connections to create a Docker Registry service connection that can connect to your ACR.
In the pipeline, add the Docker task to build and push your Docker image to ACR.
Yours service principal on service connection is missing permissions link to documentation https://learn.microsoft.com/en-us/azure/container-registry/container-registry-roles?tabs=azure-cli. You can use custom role or build like contributor on resource group level. Example of custom role and allowed actions "Microsoft.ContainerRegistry/registries/push/write",

Azure Devops - enable access to keyvault

I'm using the Microsoft Extension to access KeyVaults from Azure DevOps to fetch a secret from the vault. I'm getting this error message which appears to say that I need to allow rights the Azure Devops agent access to the keyvault.
"Could not fetch access token for Managed Service Principal. Please configure Managed Service Identity (MSI) for virtual machine 'https://aka.ms/azure-msi-docs'. Status code: 400, status message: Bad Request""
I have this running on a separate test subscription where the AzureDevOps account has contributor access under Role Assignments, same on the PROD subscription where the error message is coming up.
Any insights would be greatly appreciated.
THanks,
This seems to be an issue with Azure keyvaults defined with service endpoints. As Azure DevOps is not a trusted service it does not have access to the endpoint. The workaround is to whitelist the ip of the agent right from the pipeline, removing it after you've obtained the secrets(figuring out how to do this now). This is referenced in here and here

Unable to access keyvault from Azure DevOps from a different resource description

I'm attempting to build out my DevOps pipeline to deploy a DataFactory, Databricks Notebooks & Azure Data Warehouse,
I have my resource subscriptions setup for both Dev and Prod. deploying to Prod is more tricky than it seems.
my keyvault has GET/LIST Permissions for both Secret & Keys for the Target DataFactory.
https://learn.microsoft.com/en-us/azure/data-factory/continuous-integration-deployment
I have used the above guide to setup my target data factory in prod - and it is stood up correctly with all the connection strings setup and keyvault permissions set.
but I am stuck on this portion :
Grant permissions to the Azure Pipelines agent The Azure Key Vault
task may fail with an Access Denied error if the proper permissions
aren't present. Download the logs for the release, and locate the .ps1
file with the command to give permissions to the Azure Pipelines
agent. You can run the command directly, or you can copy the principal
ID from the file and add the access policy manually in the Azure
portal. Get and List are the minimum permissions required.
when I deploy my release I get the following error on the KeyVault task :
The specified Azure service connection needs to have Get, List secret management permissions on the selected key vault. To set these permissions, download the ProvisionKeyVaultPermissions.ps1 script from build/release logs and execute it, or set them from the Azure portal
I've added this power shell script ProvisionKeyVaultPermissions.ps1 to my repo and added it to my task but it just runs forever ? unsure if I'm missing something here.
hope this is clear/ please ask for any additional info.
I wonder if it's the DevOps service connection that's missing the permissions.
You can check access policies for the vault from the console. You should see your service connection as an APPLICATION; it needs the GET and LIST privileges as the document your following says. My understanding is that these are privileges for the account that's deploying your code, rather than the account that will run your code.

Resources