Skip to content

Instantly share code, notes, and snippets.

@takekazuomi
Created July 1, 2018 23:43
Show Gist options
  • Save takekazuomi/6011605070a8a362ca8364cfce7b681e to your computer and use it in GitHub Desktop.
Save takekazuomi/6011605070a8a362ca8364cfce7b681e to your computer and use it in GitHub Desktop.
getting a functions secrets
#Requires -Version 5.1
#Requires -Modules AzureRM.Profile, AzureRM.Websites
[CmdletBinding()]
Param(
$Name
)
# https://github.com/projectkudu/kudu/wiki/Functions-API#getting-a-functions-secrets
# https://github.com/Azure/azure-powershell/issues/4212#issuecomment-338366729
$ErrorActionPreference = "Stop"
$ProgressPreference='SilentlyContinue'
Set-StrictMode -Version latest
$webapp = Get-AzureRmWebApp -Name $Name -ErrorAction Stop
# post /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Web/sites/{functionapp}/functions/MyFunction/listsecrets?api-version=2015-08-01
# /subscriptions/ff05d8ad-12ee-4c68-97bb-6b52efa1c92e/resourceGroups/kyrtmsgsync02-rg/providers/Microsoft.Web/sites/kyrtmsgsync02fn?api-version=2015-08-01
[PSCustomObject]$result = Invoke-AzureRmResourceAction -ResourceGroupName $webapp.ResourceGroup `
-ResourceType Microsoft.Web/sites `
-ResourceName "$Name"`
-Action "functions/ApiEndpoint/listsecrets" -ApiVersion 2015-08-01 `
-Force
[uri]$u = $result.trigger_url
Write-Output ("Key: " + $result.Key)
Write-Output ("Endpoint: " + $u.ToString().Replace("/ApiEndpoint"+$u.Query, ""))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment