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

scm_type = "LocalGit" causes setting to be reapplied in azurerm_function_app #8676

Closed
ghost opened this issue Sep 29, 2020 · 8 comments · Fixed by #10386
Closed

scm_type = "LocalGit" causes setting to be reapplied in azurerm_function_app #8676

ghost opened this issue Sep 29, 2020 · 8 comments · Fixed by #10386
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Sep 29, 2020

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 (and AzureRM Provider) Version

Terraform v0.12.29
+ provider.azurerm v2.29.0

Affected Resource(s)

  • azurerm_function_app

Terraform Configuration Files

resource "azurerm_function_app" "functions" {
  name                = "test-functions
  location            = local.location
  resource_group_name = local.resource_group_name
  app_service_plan_id = azurerm_app_service_plan.appservice.id

  storage_account_name       = azurerm_storage_account.functions.name
  storage_account_access_key = azurerm_storage_account.functions.primary_access_key

  https_only = true

  version = "~2"

  site_config {
    always_on                 = true
    scm_type                  = "LocalGit"
    use_32_bit_worker_process = false
  }
}

Debug Output

[section of plan output:]
      ~ site_config {
            always_on                   = true
            ftps_state                  = "AllAllowed"
            http2_enabled               = false
            ip_restriction              = []
            min_tls_version             = "1.0"
            pre_warmed_instance_count   = 0
            scm_ip_restriction          = []
          + scm_type                    = "LocalGit"
            scm_use_main_ip_restriction = false
            use_32_bit_worker_process   = false
            websockets_enabled          = false

            cors {
                allowed_origins     = [
                    "https://functions-next.azure.com",
                    "https://functions-staging.azure.com",
                    "https://functions.azure.com",
                ]
                support_credentials = false
            }
        }
[/end plan output]

Error: failed to create App Service Source Control for "test-functions" (Resource Group "test-rg"): web.AppsClient#CreateOrUpdateSourceControl: Failure sending request: StatusCode=400 -- Original Error: Code="BadRequest" Message="Operation not supported: RepoUrl https://test-functions.scm.azurewebsites.net is not supported." Details=[{"Message":"Operation not supported: RepoUrl https://test-functions.scm.azurewebsites.net is not supported."},{"Code":"BadRequest"},{"ErrorEntity":{"Code":"BadRequest","ExtendedCode":"51024","Message":"Operation not supported: RepoUrl https://test-functions.scm.azurewebsites.net is not supported.","MessageTemplate":"Operation not supported: {0}","Parameters":["RepoUrl https://test-functions.scm.azurewebsites.net is not supported."]}}]

Panic Output

Expected Behavior

Running terraform apply for a second time shouldn't need to re-add the scm_type setting.

Actual Behavior

Running terraform apply a second time tries to re-set the scm_type setting.

Steps to Reproduce

  1. terraform apply

Important Factoids

None

References

https://github.com/terraform-providers/terraform-provider-azurerm/pull/7945/files#diff-22a801f99219a354ae919cbe0cf2f4a2R427

Looks like flattenFunctionAppSiteConfig is missing setting result["scm_type"]. This is read in expandFunctionAppSiteConfig.

https://github.com/terraform-providers/terraform-provider-azurerm/blob/90e16c22f96e320f1659cc6e0374535d773652ad/azurerm/internal/services/web/function_app.go#L384-L436

The corresponding function for non-function app services do set this: (flattenAppServiceSiteConfig)

https://github.com/terraform-providers/terraform-provider-azurerm/blob/90e16c22f96e320f1659cc6e0374535d773652ad/azurerm/internal/services/web/app_service.go#L1704

@ghost ghost changed the title scm_type for azurerm_function_app missing from flattenFunctionAppSiteConfig scm_type = "LocalGit" causes setting to be reapplied azurerm_function_app Sep 29, 2020
@ghost ghost changed the title scm_type = "LocalGit" causes setting to be reapplied azurerm_function_app scm_type = "LocalGit" causes setting to be reapplied in azurerm_function_app Sep 29, 2020
@TheRealWaldo
Copy link

TheRealWaldo commented Oct 27, 2020

Also seeing this same Error using azurerm v2.25.0 and terraform v0.13.4 however the resource was created with scm_type="LocalGit" originally, and worked, but now is failing when trying to apply other changes to the app_settings (adding additional env vars).

This has left us dead in the water for updating our environments without doing so manually through the Azure Portal.

To me it seems the RepoUrl is missing the corresponding /repo.git for the repository, and the API now requires it.

@TheRealWaldo
Copy link

Just updated to azurem v2.33 and terraform v0.13.5 and the problem has disappeared for me.

@ghost
Copy link
Author

ghost commented Oct 28, 2020

Thanks @TheRealWaldo - possibly this fix in azurerm v2.31 #8682 ?

@TheMacStack
Copy link

TheMacStack commented Oct 30, 2020

We are facing this same issue for azurerm_app_service when using scm_type="LocalGit"

On first deployment everything works fine, also when the tf is rerun there is no issue until a change anywhere in the app_service config in introduced then we are presented with an error:

Error: failed to update App Service Source Control for "my-app" (Resource Group "my-rg"): web.AppsClient#CreateOrUpdateSourceControl: Failure sending request: StatusCode=400 -- Original Error: Code="BadRequest" Message="Operation not supported: RepoUrl https://my-app.scm.chinacloudsites.cn is not supported." Details=[{"Message":"Operation not supported: RepoUrl https://my-app.scm.chinacloudsites.cn is not supported."},{"Code":"BadRequest"},{"ErrorEntity":{"Code":"BadRequest","ExtendedCode":"51024","Message":"Operation not supported: RepoUrl https://my-app.scm.chinacloudsites.cn is not supported.","MessageTemplate":"Operation not supported: {0}","Parameters":["RepoUrl https://my-app.scm.chinacloudsites.cn is not supported."]}}]

This is in Azure China with Terraform 0.13.5 and AzureRM 2.33.0

Also to note if the terraform is simply rerun after the above error it runs cleanly (still not good in automation)

Also just to note we cannot test with AzRM 2.34.0 due to another unrelated bug

@TheRealWaldo
Copy link

Also can confirm with @TheMacStack on editing other unrelated properties, the issue does return, still using v2.33 and v0.13.5

@ghost
Copy link

ghost commented Feb 5, 2021

This has been released in version 2.46.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.46.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Mar 1, 2021

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 as resolved and limited conversation to collaborators Mar 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants