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

eventgrid_extension exists on function but displays null value for event_grid_extension_config_key #13568

Closed
srjennings opened this issue Sep 30, 2021 · 5 comments · Fixed by #25108

Comments

@srjennings
Copy link

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

TF Version: 0.15.5
AzureRM Version: 2.76.0

Affected Resource(s)

Data Source:

  • azurerm_function_app_host_keys

Terraform Configuration Files

data "azurerm_function_app_host_keys" "func_apphostkeys" {
  name                = "functionname"
  resource_group_name = "resourcegroupname"
}

Debug Output

Debug output wasn't helpful. Issue was found in state file.

STATE EXCERPT:

    {
      "mode": "data",
      "type": "azurerm_function_app_host_keys",
      "name": "func_apphostkeys",
      "provider": "provider[\"registry.terraform.io/hashicorp/azurerm\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "default_function_key": "SANITIZED==",
            **"event_grid_extension_config_key": "",** <~~~~~ NULL VALUE IS INCORRECT
            "id": "/subscriptions/SANITIZED/resourceGroups/SANITIZED/providers/Microsoft.Web/sites/functionname",
            "master_key": "SANITIZED==",
            "name": "functionname",
            "primary_key": "SANITIZED==",
            "resource_group_name": "resourcegroupname,
            "timeouts": null
          },
          "sensitive_attributes": []
        }
      ]
    }

Panic Output

N/A

Expected Behaviour

Grab the eventgrid_extension key.

Actual Behaviour

event_grid_extension_config_key is "" in the state file.

Steps to Reproduce

  1. terraform plan

Important Factoids

N/A

References

@srjennings
Copy link
Author

I am not a Go developer but I see the following piece of code: https://github.com/hashicorp/terraform-provider-azurerm/blob/b44ea51c13981790f575c04d0d79eff94639f71f/internal/services/web/function_app_host_keys_data_source.go#:~:text=eventgridextensionconfig_extension

I think the reference is simply incorrect. I'd make a PR but may not have time right away to do so.

Running the following command in the AZ CLI returns a different key:

az rest \
--method post \
--uri /subscriptions/SANITIZED/resourceGroups/SANITIZED/providers/Microsoft.Web/sites/functionname/host/default/listkeys?api-version=2019-08-01 \
--query systemKeys

@srjennings
Copy link
Author

srjennings commented Sep 30, 2021

Looks like this is dependent on which runtime is set. If the runtime is 1.x, eventgridextensionconfig_extension is used. Whereas version 2.x+ is eventgrid_extension:
https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-event-grid-trigger?tabs=python%2Cbash#get-the-system-key

@abilous-ti
Copy link

abilous-ti commented Nov 15, 2023

@jackofallops @rcskosir I am facing same issue.
event_grid_extension_config_key is empty

I am using Function ~4
Is it a bug?

@markrzasa
Copy link
Contributor

markrzasa commented Mar 1, 2024

Hi Everyone, I submitted a PR to fix this problem.

In the meantime, in case it helps, one way to work around this problem is using azapi:

data "azapi_resource_action" "function_keys" {
  type                   = "Microsoft.Web/sites@2022-03-01"
  resource_id            = azurerm_linux_function_app.test.id
  action                 = "host/default/listkeys"
  method                 = "POST"
  response_export_values = ["*"]
}

The key can then be accessed with jsondecode(data.azapi_resource_action.function_keys.output)["systemKeys"]["eventgrid_extension"].

Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants