skip to Main Content

I have Angular project, that I want to build to Azure Web App

I created this yaml to build and deploy

trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '18.x'
  displayName: 'Install Node.js'


# - task: Npm@1
#   inputs:
#     command: 'install'
#     workingDir: 'schooly-angular'

- script: npm install -g @angular/cli
  displayName: 'npm install -g @angular/cli'

- script:  yarn
  displayName: 'yarn install'

- script: ng build --prod
  displayName: 'ng build'

- task: PublishBuildArtifacts@1

- task: AzureRmWebAppDeployment@4
  inputs:
    ConnectionType: 'AzureRM'
    azureSubscription: 'Azure subscription 1 (*********)'
    appType: 'webAppLinux'
    WebAppName: 'marifit-admin'
    packageForLinux: 'dist/'

But I get this error when try to build

enter image description here

Clicking Authorize, doesn’t helps

ow I can solve this?

2

Answers


  1. It seems you do not have permission regard on the subscription Azure subscription 1 (*********) or this subscription does not exist. When edit YAML pipeline, click the Settings to show assistance >> choose your subscription >> click Authorize to create a service connection for this subscription.

    enter image description here

    If the authorization failed, means you do not have enough permission regard on that subscription. You need to get contributor or owner role regard on the subscription. To get related permission, you need get help from subscription owner. Here is Assign a user as an administrator of an Azure subscription for reference.

    Login or Signup to reply.
  2. I have tried reproducing in my environment and got below results so sharing it here as further reference:

    task: AzureRmWebAppDeployment@4
        inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: 'Azure subscription 1 (*********)'
        appType: 'webAppLinux'
        WebAppName: 'marifit-admin'
        packageForLinux: 'dist/'
    

     The error seems the service connection used here was not existed. To create a proper service connection, follow the below steps. 

    Step 1: Create a service principle for the subscription where the application resources are hosted using the below command in the cloud shell.    

    $az ad sp create-for-rbac –name <service-principle-name> --scope /subscriptions/<subscription-id>
    

     enter image description here 

    Make note of make note of password, appID and tenantID. 

    Step 2: Create a service connection using the service principle just like mentioned in Step 1.

     Go to project settings > service connections > click on create new service connection. enter image description here enter image description here

    After filing all the details click on verify to confirm it is valid connection.

    enter image description here
    .
    enter image description here enter image description here 

    Make sure the azure subscription name above task match with the service connection name

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search