简体   繁体   English

无法在 Azure DevOps 中构建 angular 项目

[英]Cannot build angular project in Azure DevOps

I have Angular project, that I want to build to Azure Web App我有 Angular 项目,我想构建到 Azure Web App

I created this yaml to build and deploy我创建了这个 yaml 来构建和部署

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.您似乎没有订阅 Azure 订阅 1 (*********) 的权限,或者此订阅不存在。 When edit YAML pipeline, click the Settings to show assistance >> choose your subscription >> click Authorize to create a service connection for this subscription.编辑 YAML 管道时,单击设置以显示帮助 >> 选择您的订阅 >> 单击授权为此订阅创建服务连接。

在此处输入图像描述

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.这里有Assign a user as administrator of an Azure subscription供参考。

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.第 1 步:在云 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.记下密码、appID 和 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确保上面任务中的 azure 订阅名称与服务连接名称匹配

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Azure Devops 的项目中触发另一个构建 - Trigger another build exist in project in Azure Devops Azure DevOps 构建无法加载引用的程序集 - Azure DevOps build cannot load referenced assemblies Azure DevOps - Angular 项目构建失败并出现错误:Npm 失败并返回代码:3 - Azure DevOps - Angular project build failing with error: Npm failed with return code: 3 Azure DevOps 如何使用对另一个解决方案中的另一个项目的引用来构建项目 - Azure DevOps how to build project with references to another project in another solution .net 核心单元测试项目未能在 Azure Devops 管道中构建 - .net core unit test project failing to build in Azure Devops pipeline 在 Azure devops (CI) 中构建项目不会构建所有项目 - Building Project in Azure devops(CI) doesnt build all projects Azure Devops - 构建项目,删除一些文件和 zip 一个文件夹 - Azure Devops - Build project, delete some files and zip a folder 在Azure DevOps上运行DockerFile构建命令时找不到项目 - Project not found when running DockerFile build command on Azure DevOps 在Azure DevOps上运行DockerFile build命令时找不到项目依赖项 - Project dependency not found when running DockerFile build command on Azure DevOps Azure Devops Build Pipeline 用于具有多种项目类型的解决方案 - Azure Devops Build Pipeline for solution with multiple project types
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM