Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error StatusCode=0 when creating Function App #1271

Closed
mirogta opened this issue May 22, 2018 · 5 comments
Closed

Error StatusCode=0 when creating Function App #1271

mirogta opened this issue May 22, 2018 · 5 comments
Labels

Comments

@mirogta
Copy link

mirogta commented May 22, 2018

Getting the following error when deploying a Function App.

Error: Error applying plan:

1 error(s) occurred:

It's in a Consumption plan, however not sure if it is because of that, haven't tried to deploy with an App Service Plan

It's a very simple deployment following the Example Usage (in a Consumption Plan) here:
https://www.terraform.io/docs/providers/azurerm/r/function_app.html

What actually happens is that it looks like the Function App is created, because when I navigate to the App Service Plan, it does show it there, but when I select it then it does not show it. It also does not show it under the Function App pane. However when I try to create a new Function App with the same name, it says that it can't be created because of a conflicting name. So it is somehow stuck, the Function App exists in Azure but is not visible or accessible. The only way to get around this problem is to delete the whole resource group and create the Function App manually. I can't delete just the App Service Plan, since it contains a Function App but can't delete the Function App because Azure doesn't actually show it anywhere and it can't navigate to it.

Terraform Version

Terraform v0.11.7

  • provider.azurerm v1.5.0
  • provider.random v1.2.0

Affected Resource(s)

  • azurerm_function_app.function

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

Debug Output

https://gist.github.com/mirogta/2a6478b2813d2b3ef142d855562f99c1

Expected Behavior

Function App should be created.

Actual Behavior

  • Resource group is created
  • Storage account is created
  • App Service Plan is created (with kind = "FunctionApp")
  • It looks like the Function App is created (because the function app name becomes unavailable for other Function Apps) and is displayed under App Service Plan -> Apps
  • However the Function App is not accessible anywhere - either from the App Service Plan -> Apps link or via "Function Apps" link in Azure Portal or directly via Azure search bar in Azure Portal.
@tombuildsstuff
Copy link
Contributor

hey @mirogta

Thanks for opening this issue :)

Taking a look at the API response here - it appears the connection dropped (since you're getting an EOF) - out of interest are you running behind a corporate proxy of any kind? Do you also see this issue if you re-run terraform apply?

Given the name for a Function App (and thus App Service) needs to be globally unique - out of interest do you see the same issue when using a more unique name (e.g. random32017name)?

Thanks!

@mirogta
Copy link
Author

mirogta commented May 23, 2018

Hi @tombuildsstuff

We are running behind a corporate proxy.

When I rerun terraform apply then it fails with an error saying that the function name has to be unique.

I have modified the actual function name to test-function just here so that you can't see the original name - the actual name I'm using is definitely unique but unfortunately I can't expose it to public.

Thanks

@tombuildsstuff
Copy link
Contributor

@mirogta

I have modified the actual function name to test-function just here so that you can't see the original name - the actual name I'm using is definitely unique but unfortunately I can't expose it to public.

👍

We are running behind a corporate proxy.

Thanks for confirming that - so that we can rule out the environment specific configuration - would you be able to run Terraform with the TF_LOG environment variable set to DEBUG e.g. TF_LOG=DEBUG terraform apply this will display the raw HTTP Requests/Responses in the console.

In that log - would you be able to post the (sanitized e.g. without the Authorization header) HTTP Request and Response somewhere? That should allow us to rule out something environment specific.

When I rerun terraform apply then it fails with an error saying that the function name has to be unique.

Interesting - out of interest is this resource visible in the API at all? You can see this at https://resources.azure.com and then navigating down (subscriptions -> [name] -> resourceGroups -> [name] -> providers -> Microsoft.Web -> sites -> [name]) - if this exists. I'm not using a Proxy - but the following example is working for me; so if this isn't appearing it'd be good if you could confirm if this works:

resource "azurerm_resource_group" "test" {
  name     = "tharvey-devrg"
  location = "westeurope"
}

resource "azurerm_storage_account" "test" {
  name                     = "tharveydevsa76"
  resource_group_name      = "${azurerm_resource_group.test.name}"
  location                 = "${azurerm_resource_group.test.location}"
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

resource "azurerm_app_service_plan" "test" {
  name                = "tharvey-devasp"
  location            = "${azurerm_resource_group.test.location}"
  resource_group_name = "${azurerm_resource_group.test.name}"

  sku {
    tier = "Standard"
    size = "S1"
  }
}

resource "azurerm_function_app" "test" {
  name                      = "tom-functionapp"
  location                  = "${azurerm_resource_group.test.location}"
  resource_group_name       = "${azurerm_resource_group.test.name}"
  app_service_plan_id       = "${azurerm_app_service_plan.test.id}"
  version                   = "~1"
  storage_connection_string = "${azurerm_storage_account.test.primary_connection_string}"
}

Thanks,
Tom

@mirogta
Copy link
Author

mirogta commented May 25, 2018

Hi Tom,

I've raised a support ticket with Microsoft to also see what is happening on their end in Azure, since whatever works or not in this terraform provider, it leaves an invisible resource in Azure which seems like at least a small bug on their side.

I have tried a minimal example with a few modifications:

  • kind = "FunctionApp"
  • sku { tier = "Dynamic" size = "Y1" }

(Un)fortunately this minimal example works OK.

resource "azurerm_resource_group" "resourcegroup" {
  name     = "mirogta-function"
  location = "northeurope"
}

resource "random_string" "storage_account_name" {
  length  = 24
  special = false
  upper   = false
}

resource "azurerm_storage_account" "storage" {
  name                     = "${random_string.storage_account_name.result}"
  resource_group_name      = "${azurerm_resource_group.resourcegroup.name}"
  location                 = "${azurerm_resource_group.resourcegroup.location}"
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

resource "azurerm_app_service_plan" "app_service" {
  name                = "mirogta-function-plan"
  resource_group_name = "${azurerm_resource_group.resourcegroup.name}"
  location            = "${azurerm_resource_group.resourcegroup.location}"
  kind                = "FunctionApp"

  sku {
    tier = "Dynamic"
    size = "Y1"
  }
}

resource "azurerm_function_app" "function" {
  name                      = "mirogta-function"
  resource_group_name       = "${azurerm_resource_group.resourcegroup.name}"
  location                  = "${azurerm_resource_group.resourcegroup.location}"
  app_service_plan_id       = "${azurerm_app_service_plan.app_service.id}"
  version                   = "~1"
  storage_connection_string = "${azurerm_storage_account.storage.primary_connection_string}"
  https_only                = "true"
}

This makes me think that that particular Function App resource with that particular name that was failing got somehow stuck in Azure, even after destroying the whole resource group and trying to recreate it.

The Function App resource was not visible in https://resources.azure.com

Closing as I can't reproduce the error now.

@ghost
Copy link

ghost commented Mar 31, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants