5

I have an Azure pipeline which builds an asp-net core project and build from it a docker image and push it to Azure Container Registry.

This pipeline is made from an azure-pipelines.acr.yml file. Each git push operation that I perform to my Deployments branch is turned it in a new build into my pipeline.

Until here I have a CI pipeline, in order to integrate each new change in the master branch to my pipeline.

But, after to finish each build, I have to run a new instance of that image pushed into my container registry, and deploy it as a new App service, all this process manually from Azure portal services.

enter image description here

I have been reading and that's I need is perform a continuous deployment using my Azure pipeline. In my azure-pipelines.acr.yml I have the CI pipeline workflow with the following steps:

pool:
  vmImage: 'ubuntu-16.04' # other options: 'macOS-10.13', 'vs2017-win2016'

variables:
  buildConfiguration: 'Release'
  imageName: 'zcrm365:$(Build.BuildId)'
  dockerId: 'zcrm365' # This is my registry name access key
  dockerPassword: 'my password' # Password access key  
  # I should create an environment variables to dockerId and dockerPassword


steps:
# Build a docker image
- script: |
    docker build -t $(dockerId)/$(imageName) -f ZAccountSyncService/Dockerfile .  # add options to this command to meet your needs 
    docker build -t $(dockerId).azurecr.io/$(imageName) -f ZAccountSyncService/Dockerfile .
    docker login -u $(dockerId) -p $(dockerPassword) $(dockerId).azurecr.io
    docker images
    docker push $(dockerId).azurecr.io/$(imageName)


##### DEPLOY A WEB APP ########
- script: dotnet publish --output $(Build.ArtifactStagingDirectory)  

# Publish the output of our build to Azure Pipelines
- task: PublishBuildArtifacts@1

- task: DotNetCoreCLI@2
  inputs:
    command: publish
    # our repository seems has no web project
    publishWebProjects: False
    # We should specify your .csproj in project(s) option.
    projects: "" 
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: True



# CREATING AN Azure App Service Deploy task 

- task: AzureRmWebAppDeployment@3 
  inputs:
    # Is this my ID Subscription? 
    azureSubscription: '4e65758d-dbf5-456f-bb55-6b92273772dd'

    WebAppName: 'zcrm-365'
    Package: $(System.ArtifactsDirectory)/**/*.zip 

And, in my build pipeline, I get this output error:

Job Job: Step input azureSubscription references service connection ID SUBSCRIPTION which could not be found. The service connection does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz.

I am trying this process and I have an Azure Subscription active, but, I cannot setup the connection to it.

How to can I setup my service connection in order to connect to Azure Resource Manager and may be create my app service?

The idea is make this step in order to advance to the creation of my release pipeline with the CI process that I am performing.

bgarcial
  • 2,915
  • 10
  • 56
  • 123
  • whats the error when you try to set it up? it creates a popup, so you should allow popups temporary to create that – 4c74356b41 Feb 12 '19 at 14:58
  • @4c74356b41 Sorry I don't understand I am creating the task from a .yml file and not using the visual designer, may be in this one is where the popup is created? – bgarcial Feb 12 '19 at 15:01
  • I am trying this process and I have an Azure Subscription active, but, I cannot setup the connection to it. - i was referring to this – 4c74356b41 Feb 12 '19 at 15:04
  • @4c74356b41 That's the same problem that I have ... but I don't understand when you tell me that > it creates a popup, so you should allow popups temporary to create that Can you give more details please? – bgarcial Feb 12 '19 at 15:08

1 Answers1

0

you were referring to the correct documentation link https://learn.microsoft.com/en-us/azure/devops/pipelines/library/connect-to-azure?view=azure-devops to set the connection up by creating new service connection.

As per your build pipeline error 'service connection does not exist or has not been authorized for use', the issue should fall under one of the below.

#1. You haven't created the service connection with the name '4e65758d-dbf5-456f-bb55-6b92273772dd'.

#2. The service connection which you have created doesn't have permission to connect to intended Azure subscription.

Option #1:

If the issue fall under option #1 then please update your yml file azureSubscription: 'YOURSERVICECONNECTIONNAME' (but not the subscription ID in this case). For illustration, please refer this https://learn.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops#use-a-service-connection link.

Option #2: If the issue fall under option #2 then please provide below information to diagnose the issue in a better way.

2a. Which option you have followed while creating service connection. Is it either 'Service Principal Authentication' or 'Managed Identity Authentication' ?

2b.If it is 'Service Principal Authentication' then what option did you select at 'Scope level'. Is it either 'Subscription' or 'ManagementGroup' ?

2c.If it is 'Subscription' or 'ManagementGroup' option, did you click on 'use the automated version of the service connection dialog' and provide all the details and then did you click on 'Verify connection' ? And was the connection verified successfully ?

Hope this helps!! Cheers!! :)

KrishnaG
  • 3,340
  • 2
  • 6
  • 16