Terraform-provider-azurerm: Manually deleting function app and running terraform apply errors with Error making Read request on AzureRM Function App AppSettings

Created on 3 Aug 2018  ·  5Comments  ·  Source: terraform-providers/terraform-provider-azurerm

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.7

Affected Resource(s)

azurerm v1.12.0

Terraform Configuration Files

# create the resource group
resource "azurerm_resource_group" "rg" {
  name     = "${var.resourceGroupName}"
  location = "${var.resourceGroupLocation}"
}

# create the app insights plan
resource "azurerm_application_insights" "ai" {
  name                = "${var.appInsightsName}"
  location            = "${azurerm_resource_group.rg.location}"
  resource_group_name = "${azurerm_resource_group.rg.name}"
  application_type    = "Web"
}

# create the storage account
resource "azurerm_storage_account" "strg" {
  name                     = "${var.storageAccountName}"
  location                 = "${azurerm_resource_group.rg.location}"
  resource_group_name      = "${azurerm_resource_group.rg.name}"
  account_kind             = "StorageV2"
  account_tier             = "Standard"
  account_replication_type = "LRS"
  access_tier              = "Cool"
}

# create the app service plan
resource "azurerm_app_service_plan" "asp" {
  name                = "${var.appServicePlanName}"
  location            = "${azurerm_resource_group.rg.location}"
  resource_group_name = "${azurerm_resource_group.rg.name}"
  kind                = "FunctionApp"

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

# create the function app
resource "azurerm_function_app" "function" {
  name                      = "${var.functionAppName}"
  location                  = "${azurerm_resource_group.rg.location}"
  resource_group_name       = "${azurerm_resource_group.rg.name}"
  app_service_plan_id       = "${azurerm_app_service_plan.asp.id}"
  storage_connection_string = "${azurerm_storage_account.strg.primary_connection_string}"

  app_settings {
    "AppInsights_InstrumentationKey" = "${azurerm_application_insights.ai.instrumentation_key}"
        "StatusPageContainer" = "${azurerm_storage_account.strg.primary_connection_string}"
  }
}

Debug Output

Panic Output

Expected Behavior

terraform apply should generate a create plan for the function app

Actual Behavior

When running terraform apply the following error is thrown during the refresh state step.
Error refreshing state.
azurerm_function_app.function: Error making Read request on AzureRM function App AppSettings "xxxxx": web.AppsClient#ListApplicationSettings: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The Resource 'Microsoft.Web/sites/xxxxx" under resource group 'xxxxxxxx' was not found."

Steps to Reproduce

  1. terraform apply
  2. Manually delete function app via Azure portal.
  3. terraform apply

Important Factoids

If deleting a storage account manually and running terraform apply, the create plan is generated successfully.

bug good first issue servicfunctions

All 5 comments

Seems we need to check for 404 reply here:

Similar to how it's done just a few lines above, with utils.ResponseWasNotFound(resp.Response).

@catsby Can I take this issue up and work on it? If not assigned to someone else.

@DexterPOSH I'm not active on this project, but it's likely OK to pick up, thanks!

hi @Mark-Wilkins @DexterPOSH

Just to let you know that this has been released as a part of v1.18 of the AzureRM Provider (the full changelog is available here). You can upgrade to this by specifying the version in the provider block (as shown below) and then running terraform init -upgrade

provider "azurerm" {
  version = "=1.18.0"
}

Thanks!

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!

Was this page helpful?
0 / 5 - 0 ratings