I have been trying to deploy my Ruby on Rails application to Azure App Services for a couple days now. I'm getting really frustrated trying to figure this out. I'm new to Ruby and I've never used rbenv
.
I am trying to use Azure Pipelines to deploy my code to an Azure App Services Deployment Slot.
I observed the following:
rbenv
.In an attempt to ignore the minor version I had updated my azure-pipeline.yml
to only reference Ruby 2.6
.
steps:
- task: UseRubyVersion@0
inputs:
versionSpec: '~> 2.6'
I am using this AzureWebApp Task to do the deployment into the slot, which is uploading the code. I can tell by the error messages when I'm experimenting.
- 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
When I tried to use 2.6.2 in my azure-pipeline.yml
I saw the following error:
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://learn.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
When I built the code with 2.6.6 then my Pipeline is working. However, my application is failing to start and the App Logs show me this error:
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)
I've read online that the same environment you're developing, building, and running your application should be the same, but that's not possible given my requirements. Is there any other option to get this to work?
Finally, I was reading that rbenv
can take it's Ruby version from an environment variable. I set this variable in the Azure App Service from the Console, yet it didn't change the error above.
Please take a look at my GitHub repo if you have the time to try and help me resolve this painful issue. https://github.com/wheelers-websites/CloudGuruChallenge_21.02/tree/main/verify-app
You can run this task on a self-hosted agent with your own Ruby versions. To run this task on a self-hosted agent, set up Agent.ToolsDirectory
by following the instructions below. The tool name to use is "Ruby."