gpt4 book ai didi

node.js - 如何将 Azure DevOps 构建管道连接到专用终结点

转载 作者:行者123 更新时间:2023-12-03 05:31:42 25 4
gpt4 key购买 nike

我正在尝试对通过 Azure DevOps 构建管道托管在 Azure 应用服务中的 node.js 应用程序执行 Mocha 测试。下面是我正在使用的发布管道代码

    # Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- Test

pool:
vmImage: 'vs2017-win2016'

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

- script: |
npm install
- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'npm run local

- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: 'test-results.xml'

- task: ArchiveFiles@2
displayName: 'Archive $(System.DefaultWorkingDirectory)'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/node.zip'

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'

当我运行构建时,出现以下错误

{"name":"xxxx","hostname":"xxxx","pid":xxxx,"level":50,"msg":"Error while connecting sql database xxxx-dev","time":"2020-11-17T11:37:26.852Z","v":0} 
[0] {"name":"xxxxx","hostname":"xxxxxx","pid":xxxx,"level":50,"err":{"message":"Reason: An instance-specific error occurred while establishing a connection to SQL Server. Connection was denied since Deny Public Network Access is set to Yes (https://learn.microsoft.com/azure/azure-sql/database/connectivity-settings#deny-public-network-access). To connect to this server, use the Private Endpoint from inside your virtual network (https://learn.microsoft.com/azure/sql-database/sql-database-private-endpoint-overview#how-to-set-up-private-link-for-azure-sql-database).","name":"ConnectionError","stack":"ConnectionError: Reason: An instance-specific error occurred while establishing a connection to SQL Server. Connection was denied since Deny Public Network Access is set to Yes (
[0] {"name":"xxxx-device-controller","hostname":"xxxxx","pid":xxxx,"level":50,"msg":"Error while attempting to complete call","time":"2020-11-17T11:37:26.852Z","v":0}

有没有办法直接在App服务中运行测试?或者如何建立连接

最佳答案

为了连接到 SQL 数据库,IP 应该被列入白名单(在数据库的概览选项卡中设置服务器防火墙。因此,您需要以下 IP 地址构建服务器。由于此 IP 可能会随着每次构建而更改,因此需要从管道中添加它。

如何做到这一点已在this article中讨论过。 。您需要稍微修改命令:

  • 将 IP 列入白名单:New-AzureRmSqlServerFirewallRule,而不是 Add-AzWebAppAccessRestrictionRule。您应该能够获取所有必需的参数,请参阅 documentation .
  • 将使用 Remove-AzureRmSqlServerFirewallRule 从管道中删除 IP 地址

关于node.js - 如何将 Azure DevOps 构建管道连接到专用终结点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64877980/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com