如何使用 Azure Pipelines 将 Ruby 部署到 Azure 应用服务?
How to Deploy Ruby using Azure Pipelines to Azure App Services?
几天来,我一直在尝试将 Ruby on Rails 应用程序部署到 Azure App Services。试图弄清楚这一点我真的很沮丧。我是 Ruby 的新手,我从未使用过 rbenv
。
目标
我正在尝试使用 Azure Pipelines 将我的代码部署到 Azure 应用服务部署槽。
进程
我观察到以下情况:
- Azure 应用服务正在使用由
rbenv
管理的 Ruby 2.6.2。
- Azure 管道正在使用 Ruby 2.6.6.
为了忽略次要版本,我将 azure-pipeline.yml
更新为仅引用 Ruby 2.6
.
steps:
- task: UseRubyVersion@0
inputs:
versionSpec: '~> 2.6'
我正在使用此 AzureWebApp 任务将部署部署到正在上传代码的插槽中。我可以通过实验时的错误消息来判断。
- task: AzureWebApp@1
inputs:
azureSubscription: 'WheelerLearning/wheeler146'
appName: 'wheeler-verify-app-site'
deploymentMethod: 'zipDeploy'
package: $(System.DefaultWorkingDirectory)/$(appDir)
slotName: 'stg'
https://github.com/wheelers-websites/CloudGuruChallenge_21.02/blob/main/azure-pipelines.yml
Azure 管道错误
当我尝试在 azure-pipeline.yml
中使用 2.6.2 时,我看到了以下错误:
2021-04-01T03:26:44.8712433Z ##[section]Starting: UseRubyVersion
2021-04-01T03:26:44.8719527Z ==============================================================================
2021-04-01T03:26:44.8719967Z Task : Use Ruby version
2021-04-01T03:26:44.8720409Z Description : Use the specified version of Ruby from the tool cache, optionally adding it to the PATH
2021-04-01T03:26:44.8720799Z Version : 0.182.0
2021-04-01T03:26:44.8721102Z Author : Microsoft Corporation
2021-04-01T03:26:44.8721535Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/tool/use-ruby-version
2021-04-01T03:26:44.8722005Z ==============================================================================
2021-04-01T03:26:45.3163457Z ##[warning]It is not recommended to specify exact version on Microsoft-Hosted agents. Patch version of Ruby can be replaced by new one on Hosted agents without notice and build stops to work. it is recommended to specify only major or major and minor version (Example: `2` or `2.4`)
2021-04-01T03:26:45.3185530Z ##[error]Version spec 2.6.2 for architecture %25s did not match any version in Agent.ToolsDirectory.
Available versions: /opt/hostedtoolcache
2.5.8,2.6.6,2.7.2,3.0.0
If this is a Microsoft-hosted agent, check that this image supports side-by-side versions of Ruby at https://aka.ms/hosted-agent-software.
If this is a self-hosted agent, see how to configure side-by-side Ruby versions at https://go.microsoft.com/fwlink/?linkid=2005989.
2021-04-01T03:26:45.3229225Z ##[section]Finishing: UseRubyVersion
Azure 应用服务错误
当我使用 2.6.6 构建代码时,我的管道正在运行。但是,我的应用程序无法启动并且应用程序日志显示此错误:
2021-04-02T04:27:01.516359889Z _____
2021-04-02T04:27:01.516391591Z / _ \ __________ _________ ____
2021-04-02T04:27:01.516396291Z / /_\ \___ / | \_ __ \_/ __ \
2021-04-02T04:27:01.516400091Z / | \/ /| | /| | \/\ ___/
2021-04-02T04:27:01.516403592Z \____|__ /_____ \____/ |__| \___ >
2021-04-02T04:27:01.516407092Z \/ \/ \/
2021-04-02T04:27:01.516410492Z A P P S E R V I C E O N L I N U X
2021-04-02T04:27:01.516413692Z
2021-04-02T04:27:01.516416692Z Documentation: http://aka.ms/webapp-linux
2021-04-02T04:27:01.516419892Z Ruby quickstart: https://aka.ms/ruby-qs
2021-04-02T04:27:01.516423093Z Ruby version 2.6.2
2021-04-02T04:27:01.516426193Z Note: Any data outside '/home' is not persisted
2021-04-02T04:27:02.189573568Z Starting OpenBSD Secure Shell server: sshd.
2021-04-02T04:27:03.195641038Z Bundle install with no 'without' options
2021-04-02T04:27:03.202609004Z Defaulting gem installation directory to /tmp/bundle
2021-04-02T04:27:03.202897520Z Defaulting site config directory to /home/site/config
2021-04-02T04:27:03.204055381Z Generating a secret key base
2021-04-02T04:27:03.692631856Z RAILS_ENV not set, default to production
2021-04-02T04:27:03.692659357Z Removing any leftover pids if present
2021-04-02T04:27:03.692723961Z rbenv: version `ruby-2.6' is not installed (set by /home/site/wwwroot/.ruby-version)
2021-04-02T04:27:03.744540384Z Running bundle check
2021-04-02T04:27:04.261191335Z rbenv: version `ruby-2.6' is not installed (set by /home/site/wwwroot/.ruby-version)
2021-04-02T04:27:04.682632482Z rbenv: version `ruby-2.6' is not installed (set by /home/site/wwwroot/.ruby-version)
2021-04-02T04:27:04.692844319Z missing dependencies, try redeploying
2021-04-02T04:27:05.282227084Z rbenv: version `ruby-2.6' is not installed (set by /home/site/wwwroot/.ruby-version)
我在网上看到您正在开发、构建的相同环境,运行您的应用程序应该是相同的,但鉴于我的要求,这是不可能的。是否有任何其他选项可以使其正常工作?
其他尝试
最后,我读到 rbenv
可以从环境变量中获取它的 Ruby 版本。我从控制台在 Azure 应用服务中设置了这个变量,但它并没有改变上面的错误。
如果您有时间尝试帮助我解决这个痛苦的问题,请查看我的 GitHub 存储库。
https://github.com/wheelers-websites/CloudGuruChallenge_21.02/tree/main/verify-app
您可以 运行 使用您自己的 Ruby 版本在自托管代理上执行此任务。要在自托管代理上 运行 此任务,请按照以下说明设置 Agent.ToolsDirectory
。要使用的工具名称是“Ruby”。
几天来,我一直在尝试将 Ruby on Rails 应用程序部署到 Azure App Services。试图弄清楚这一点我真的很沮丧。我是 Ruby 的新手,我从未使用过 rbenv
。
目标
我正在尝试使用 Azure Pipelines 将我的代码部署到 Azure 应用服务部署槽。
进程
我观察到以下情况:
- Azure 应用服务正在使用由
rbenv
管理的 Ruby 2.6.2。 - Azure 管道正在使用 Ruby 2.6.6.
为了忽略次要版本,我将 azure-pipeline.yml
更新为仅引用 Ruby 2.6
.
steps:
- task: UseRubyVersion@0
inputs:
versionSpec: '~> 2.6'
我正在使用此 AzureWebApp 任务将部署部署到正在上传代码的插槽中。我可以通过实验时的错误消息来判断。
- task: AzureWebApp@1
inputs:
azureSubscription: 'WheelerLearning/wheeler146'
appName: 'wheeler-verify-app-site'
deploymentMethod: 'zipDeploy'
package: $(System.DefaultWorkingDirectory)/$(appDir)
slotName: 'stg'
https://github.com/wheelers-websites/CloudGuruChallenge_21.02/blob/main/azure-pipelines.yml
Azure 管道错误
当我尝试在 azure-pipeline.yml
中使用 2.6.2 时,我看到了以下错误:
2021-04-01T03:26:44.8712433Z ##[section]Starting: UseRubyVersion
2021-04-01T03:26:44.8719527Z ==============================================================================
2021-04-01T03:26:44.8719967Z Task : Use Ruby version
2021-04-01T03:26:44.8720409Z Description : Use the specified version of Ruby from the tool cache, optionally adding it to the PATH
2021-04-01T03:26:44.8720799Z Version : 0.182.0
2021-04-01T03:26:44.8721102Z Author : Microsoft Corporation
2021-04-01T03:26:44.8721535Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/tool/use-ruby-version
2021-04-01T03:26:44.8722005Z ==============================================================================
2021-04-01T03:26:45.3163457Z ##[warning]It is not recommended to specify exact version on Microsoft-Hosted agents. Patch version of Ruby can be replaced by new one on Hosted agents without notice and build stops to work. it is recommended to specify only major or major and minor version (Example: `2` or `2.4`)
2021-04-01T03:26:45.3185530Z ##[error]Version spec 2.6.2 for architecture %25s did not match any version in Agent.ToolsDirectory.
Available versions: /opt/hostedtoolcache
2.5.8,2.6.6,2.7.2,3.0.0
If this is a Microsoft-hosted agent, check that this image supports side-by-side versions of Ruby at https://aka.ms/hosted-agent-software.
If this is a self-hosted agent, see how to configure side-by-side Ruby versions at https://go.microsoft.com/fwlink/?linkid=2005989.
2021-04-01T03:26:45.3229225Z ##[section]Finishing: UseRubyVersion
Azure 应用服务错误
当我使用 2.6.6 构建代码时,我的管道正在运行。但是,我的应用程序无法启动并且应用程序日志显示此错误:
2021-04-02T04:27:01.516359889Z _____
2021-04-02T04:27:01.516391591Z / _ \ __________ _________ ____
2021-04-02T04:27:01.516396291Z / /_\ \___ / | \_ __ \_/ __ \
2021-04-02T04:27:01.516400091Z / | \/ /| | /| | \/\ ___/
2021-04-02T04:27:01.516403592Z \____|__ /_____ \____/ |__| \___ >
2021-04-02T04:27:01.516407092Z \/ \/ \/
2021-04-02T04:27:01.516410492Z A P P S E R V I C E O N L I N U X
2021-04-02T04:27:01.516413692Z
2021-04-02T04:27:01.516416692Z Documentation: http://aka.ms/webapp-linux
2021-04-02T04:27:01.516419892Z Ruby quickstart: https://aka.ms/ruby-qs
2021-04-02T04:27:01.516423093Z Ruby version 2.6.2
2021-04-02T04:27:01.516426193Z Note: Any data outside '/home' is not persisted
2021-04-02T04:27:02.189573568Z Starting OpenBSD Secure Shell server: sshd.
2021-04-02T04:27:03.195641038Z Bundle install with no 'without' options
2021-04-02T04:27:03.202609004Z Defaulting gem installation directory to /tmp/bundle
2021-04-02T04:27:03.202897520Z Defaulting site config directory to /home/site/config
2021-04-02T04:27:03.204055381Z Generating a secret key base
2021-04-02T04:27:03.692631856Z RAILS_ENV not set, default to production
2021-04-02T04:27:03.692659357Z Removing any leftover pids if present
2021-04-02T04:27:03.692723961Z rbenv: version `ruby-2.6' is not installed (set by /home/site/wwwroot/.ruby-version)
2021-04-02T04:27:03.744540384Z Running bundle check
2021-04-02T04:27:04.261191335Z rbenv: version `ruby-2.6' is not installed (set by /home/site/wwwroot/.ruby-version)
2021-04-02T04:27:04.682632482Z rbenv: version `ruby-2.6' is not installed (set by /home/site/wwwroot/.ruby-version)
2021-04-02T04:27:04.692844319Z missing dependencies, try redeploying
2021-04-02T04:27:05.282227084Z rbenv: version `ruby-2.6' is not installed (set by /home/site/wwwroot/.ruby-version)
我在网上看到您正在开发、构建的相同环境,运行您的应用程序应该是相同的,但鉴于我的要求,这是不可能的。是否有任何其他选项可以使其正常工作?
其他尝试
最后,我读到 rbenv
可以从环境变量中获取它的 Ruby 版本。我从控制台在 Azure 应用服务中设置了这个变量,但它并没有改变上面的错误。
如果您有时间尝试帮助我解决这个痛苦的问题,请查看我的 GitHub 存储库。 https://github.com/wheelers-websites/CloudGuruChallenge_21.02/tree/main/verify-app
您可以 运行 使用您自己的 Ruby 版本在自托管代理上执行此任务。要在自托管代理上 运行 此任务,请按照以下说明设置 Agent.ToolsDirectory
。要使用的工具名称是“Ruby”。