简体   繁体   中英

Cannot build angular project in Azure DevOps

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

在此处输入图像描述

Clicking Authorize, doesn't helps

ow I can solve this?

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.

在此处输入图像描述

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.

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>

在此处输入图像描述

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. 在此处输入图像描述在此处输入图像描述

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

在此处输入图像描述 . 在此处输入图像描述在此处输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM