So, recently I was working on a hobby project in which I built an IVR via a telephony API.
Being lazy (and because it was on .Net), I hosted this directly on Azure.
So the way this service works in a nutshell is: You call a number, which then calls your web service which then answers the call and provides instructions.
What was happening was that the calls that were being sent to Azure after extended periods would go on ringing for a long time or would time out entirely.
I then remembered that Azure Web Services have an “ALWAYS ON” option which you need to turn on. If you don’t do it, Azure will wind down your instance if it does not get any traffic in 20 minutes.
When I hopped onto the Azure Dashboard panel, I noticed that the slider was disabled for me:
This only works if you have atleast a basic account.
Which is almost 6x of what I was paying.
So, a hack I discovered was to run a cron job which pings my website once every 5 minutes and keeps it always on automatically.
You could use any cron service — but I signed up for SetCronJob which I have used earlier and is quite reliable.
And for $10 / year, you can have your always on service on Azure going and I can continue being a cheap-ass :)
You know the drill. You start a new project and drag and drop the DBML file to a project to connect to a SQL (or one of the supported databases).
Only to find that the DBML file REFUSES to read changes to the connection string specified in your app.config or web.config file.
I recently figured out a clean and effective way to do this and wanted to put it out there – primarily for my own sake.
Considering you are working on a web project and have restricted your data-access layer to a DLL project – this is the worst case scenario. It is easier to have the DBML file inside of your web project and change the connection string.
Anyways, here goes. This should probably work for all scenarios.
Step 1: Add the connection string to your web.config For example:
Amazon Elastic Beanstalk has been a life saver in not only letting us deploy quickly to our staging and production servers – but also making it fairly easy to scale horizontally. However, if you want to do this under a VPC, things get complicated quickly and you’ll find yourself running into issues with no explanations.
I had to stumble and fall quite a bit before I was able to get this working consistently.
This post will give you step by step instructions on how to set this up quickly. If you follow along, you should have yourself your Elastic Beanstalk chugging along behind a VPC. I will explain wherever I can – but if something is confusing, please leave a comment.
Stage 1: Setting up your VPC
Step 1: Let’s fire up the VPC Console:
Step 2: Click on the Your VPC sub menu
Step 3: Let’s create a new VPC from scratch
Step 4: Add in a proper name tag and leave the CIDR block as: 10.0.0.0/16
Step 5: Then click on Subnets in the sub menu and Create a Subnet
Step 6: Let’s create our first subnet. Select one of the availability zones and the CIDR can be: 10.0.0.0/24
(Please note that this is a /24 and not /16 as we did for the VPC)
Step 7: Repeat this step to create another subnet. As this is going to be load balanced, we should have atlease 2 subnets. Note that this CIDR block is: 10.0.1.0/24
Also, note that this is being created in an availability zone that is different from Step 6.
Step 7.1: If you have more availability zones, repeat the steps above to create one subnet per availability zone. So you may create a 10.0.2.0/24 in us-east-1d and a 10.0.3.0/24 in us-east-1e
Step 8: We now need to modify the Auto-Assign Public IP property.
Select each of the subnets you just created from the list page and click the shown button.
Step 9: In the pop up that is displayed, ensure that the setting is checked.
Step 10: We now need to create an Internet Gateway so that your infrastructure can communicate with the rest of the interwebs.
Click the “Internet Gateway” link in the sub menu and then the “Create Internet Gateway” button.
Step 11: Just add a proper name for your Internet Gateway and we are set.
Step 12: We now attach the newly created IG to your VPC
Step 13: Just select the VPC that you had created earlier in Step 4 and hit Attach
Step 14: We now need to configure a Route Table. Select the route table that is connected to the VPC you just created.
Step 15: Once you select the route tale, scroll down and select the 2nd tab – Routes. Then click ‘Edit’
Step 16: Create a new entry for 0.0.0.0/0 and add the ID of your newly created Internet Gateway from Step 11 here. You should get a drop down.
Step 17: We then need to associate all your subnets with this route. So click on the next tab: Subnet Associations
Step 18: Select all the subnets and associate it with the Route table. Click Save. Make sure the Route Table is Main (it should be by default)
Step 19: Finally – the Security Groups. We need to create one for this configuration! Click on Security Groups in your sub menu and then on the Create button.
Step 20: Fill in sensible names and descriptions and make sure you have selected the newly created VPC from Step 04
Step 21: We now need to configure inbound rules. Add as many rules as you want here. The 0.0.0.0/0 signifies all traffic (internet data). You may want to change this as per your requirements.
Step 22: Make sure you have outbound rules configured as required. Basically the configuration allows your servers to talk (outward) to the entire internet.
Stage 2: Configuring your Elastic Beanstalk
Phew! Believe me when I tell you that the difficult bit is behind us. Creating an Elastic Beanstalk configuration based on our VPC is an easier task.
I am going to go ahead and create an Elastic Beanstalk configuration to host a web application which is load balanced and scales automatically. If you are building something else, please choose the respective options at those places.
There are a few important things to keep in mind while setting up the Elastic Beanstalk – but I’ll highlight them as required.
Step 0: Let’s fire up the Elastic Beanstalk Console
Step 1: Click on that link to start the creation of a new Application
Step 2: Choose an appropriate name and description for your application
Step 3: This tutorial deals with web servers – so that is what I am going to select here.
Step 4: Please select a configuration as per your requirements. Just make sure that the Environment Type is: Load Balancing, Auto Scaled
Step 5: To keep things simple, I am sticking to the Sample Application – but you can choose to upload your application if you know what you’re doing
Step 6: Please fill this out as you see fit.
Step 7: This one is very important! Make sure that checkbox is enabled. Else the deployment will fail without warning.
Step 8: This is your normal Elastic Beanstalk Configuration page. Please make sure you fill in appropriate values at places pointed by the arrows. It is recommended to have the Multi-AZ checkbox set.
Step 9: If you are not seeing this page, then you forgot something in Step 7. However, if you do see this page, make sure all the information is correctly filled up as shown in the image.
Step 10: Finally, we are done! Hit the Launch button to start up your application behind a VPC