skip to Main Content

The function app default function key can be obtained using the function_app_host_keys data source. However I am using deployment slots for testing, and the keys are different, so I need them for the slots too. I have tried:

data "function_app_host_keys" "slot_default_key" {
  name = "${azurerm_windows_function_app.function.name}/slotname"
  resource_group_name = azurerm_windows_function_app.function.resource_group_name
}

and

data "function_app_host_keys" "slot_default_key" {
  name = "${azurerm_windows_function_app.function.name}-slotname"
  resource_group_name = azurerm_windows_function_app.function.resource_group_name
}

That is appending the slot name separated with either / (as it sometimes appears in the portal) or - (as it appears in the URL), but neither works.

Checking the azure cli, that has an additional option for slot, but the terraform documentation does not list any. Is there a way to get the slot default key?

2

Answers


  1. Chosen as BEST ANSWER

    I looked at the debug output of az functionapp keys list with and without the -s (for slot) option, and the requests to management.azure.com differ in /slots/slotname. So I tried

    data "function_app_host_keys" "slot_default_key" {
      name = "${azurerm_windows_function_app.function.name}/slots/${azurerm_windows_function_app_slot.slot.name}"
      resource_group_name = azurerm_windows_function_app.function.resource_group_name
    }
    

    and that works.

    Replace with other azurerm_*_function_app as appropriate for your usecase—or just use names/parameters if you are not creating the function and slot yourself.


  2. Thx Jan! just a slight modification…
    use "slots" instead of "slot"

    data "function_app_host_keys" "slot_default_key" {
    name = "${...}/slots/${...}"
    ...
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search