Deploying a Ruby on Rails API to Azure Web App

159 VIEWS

· · ·

Azure Web App is the easy way to release your Ruby on Rails API. With an Azure account and any repo, you can configure and deploy your application in minutes. In this article, we’ll cover how to deploy an API stored in a Bitbucket repo.

 

Creating a Web App

To create a Web App, you need to go to “New” and search “Web App.” Then in the right panel, click on “Create.”

Now, fill in the “App name.” This name will be part of the URL to access your application. Next, choose the app subscription. (Here, I prefer to create a new Resource Group to keep it in one place.) Then, choose Linux as the OS and click on “App Service plan.” Next, fill the “App Service plan” in with a name, choose the “Location” closest to you and click on “Pricing tier.”

You need to create a new App Service plan according to your desired environment. For this test, I’m choosing the B1 in Dev/Test option. (At the time of writing, this option will be free for 30 days.) Then, click on “Apply” to finish the App Service plan creation.

Now, in the Web App panel, choose Ruby version 2.3. Unfortunately, this is the only version available here, and the most current version (as of August 2018) is 2.3.3. If your application defines a different version, you’ll need an update to use this service.

To finish, click on “Create” and wait for the deploy of the resource.

Associating the repository

On your Web App page, click on “Deployment options” to associate the repository with your project.

Choose Bitbucket as the source. (If you haven’t made this connection before, you will need to sign in with your Bitbucket account.)

Then, choose the organization, the project and the branch you want to use. (You don’t need to set up the Performance Test in this configuration.) Now, click on “Ok” to finish this association.

Under “Development options,” click on “Sync” to get the last version of your application or make a commit in the branch chosen before.

After synchronization, you can click on the status to see more about the steps to deploy your app.

And on the details page, you can see the complete log.

That’s it! To access your application, click on “Overview” to see the URL provided to your resource, and then click on the URL.

Performance test

 

Another advantage to using Azure Web App is in the ability to test an application with a load test without using any external service. To enable the test, click on “Performance Test” in the left panel. Then, click on “New” to configure a new test.

Click on “Configure test using” to choose the method that will be used in this test. Then, choose “Manual Test” and fill in the URL that will be tested. Next, click on “Done.” Now, fill in the name, location, virtual user load, and the duration of the test and click on “Run test.”

The test will be scheduled and will run. About 15 minutes later, the results will be available to analyze with the request details. The results of the test will be shown as percentages of success and errors, and performance of the hardware will be displayed as CPU and Memory. This test can be set up to be used whenever you like—Just click on “Rerun” to run the test again. This is a good way to test load after query changes are made and performance impacts need to be visualized.

Conclusion

 

There are many advantages to using Azure Web App, such as integrated auto-scaling, backups, and SSL. You can also easily configure authentication and authorization with Active Directory, Google, Facebook, Twitter, and Microsoft to block access to your application. However, it can be pricey. At the time this article was written, the Dev/Test environment used in my example started at approximately $40, and the basic production environment started at approximately $60.

Do you think you can beat this Sweet post?

If so, you may have what it takes to become a Sweetcode contributor... Learn More.

Software Engineer with experience in analysis and development of systems. Free software enthusiast and apprentice of new tech.


Discussion

Click on a tab to select how you'd like to leave your comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Menu