Above error occurs when the user doesnot have the sufficient privileges to create an application in Azure AD. See here.
If you donot want to change Users can register applications
to Yes
, which allows any user in the Azure AD tenant can register an app. You will need to ask your administrator to assign you a proper administrator role that can create and manage all aspects of app registrations.
For example Application Developer
role. See available roles and role permissions.
Users in this role can create application registrations when the "Users can register applications" setting is set to No.
Another workaround is to Create the service principal with the user already having required permissions in Azure Active Directory. In this way, you will have to configure the pipeline manually without using the Deploy to Azure Kubernetes Service
pipeline template.
1,First you will need to create below service connections:
Create Azure container Registry service connection using the service principal.
Create Kubernetes service connection.
2, When creating a new pipeline, you need to select Starter pipeline
in Configure your pipepline
page. And then add the docker and kubernete tasks in your yaml pipeline. See the example Build and push to Azure Container Registry, Deploy to Kubernetes.
You can refer to below pipeline example, and change the variables and settings accordingly.
trigger:
- master
resources:
- repo: self
variables:
dockerRegistryServiceConnection: 'ACRserviceConnectionName'
kubernetesServiceConnection: "kubernetesServiceConnectionName"
imageRepository: 'nigx'
containerRegistry: 'leviregistry.azurecr.io'
dockerfilePath: '**/Dockerfile'
tag: '$(Build.BuildId)'
imagePullSecret: 'leviregistry8720a6c7-auth'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
- upload: manifests
artifact: manifests
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
jobs:
- deployment: Deploy
displayName: Deploy
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: KubernetesManifest@0
displayName: Create imagePullSecret
inputs:
action: createSecret
secretName: $(imagePullSecret)
kubernetesServiceConnection: $(kubernetesServiceConnection)
dockerRegistryEndpoint: $(dockerRegistryServiceConnection)
- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
inputs:
action: deploy
kubernetesServiceConnection: $(kubernetesServiceConnection)
manifests: |
$(Pipeline.Workspace)/manifests/deployment.yml
$(Pipeline.Workspace)/manifests/service.yml
imagePullSecrets: |
$(imagePullSecret)
containers: |
$(containerRegistry)/$(imageRepository):$(tag)