Terraform apply error

What was the error?

I recently encountered an error that took a fair bit of effort to solve. The Terraform plan command worked fine, the error only appeared when running the apply command. The error itself was along the following lines:

Error: web.AppsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> <nil>

on .terraform/modules/myapp/app_service/main.tf line 1, in resource "azurerm_app_service" "app_service" : {

1: resource "azurerm_app_service" "app_service" {

I tried searching for this on Google but, other than finding that I wasn’t alone in encountering this issue, I didn’t find anything that could solve it.

Solving the problem

The change I was making was quite minor – adding support for the “always_on” parameter to our Azure App Service module. I had set it to be ‘true’ all the time because there is no additional cost for setting it.

To check that there wasn’t some other issue introduced from elsewhere, I rolled the change back and re-ran the apply command. This worked fine, which was reassuring but did mean that the problem was definitely with the changes I had made.

After some further Googling I discovered that the problem was actually that what I was trying to do wasn’t supported. The “Always On” setting is supported on the Basic and Standard plans, but not for the Free plan we were using for the development environment that was being deployed to.

The end result

To prevent this from happening again the change was actually straightforward: first, make the always on option a variable; ad secondly update the documentation so that it says that “always on” should only be set to true if you know that you’re using Basic or Standard plans.