[英]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.