Archive | AzureFunctions

Azure Functions (PowerShell) : Find the current FunctionApp and Function names

I was writing an Azure Function in PowerShell. I wanted to know the name of the current FunctionApp and the current Function. Since it was a timer triggered function, I couldn’t pass the names. It took me a while to to figure this out. There may be other ways, but this only way I could find it. Again, this is in PowerShell

if ($ENV:AZURE_FUNCTIONS_ENVIRONMENT  -eq "Development"){
  $CurrentFunctionAppName=$($PSScriptRoot.split("/")[-2])
  $CurrentFunctionName= $($PSScriptRoot.split("/")[-1])
}
else {
  $CurrentFunctionAppName=$($ENV:WEBSITE_SITE_NAME)
  $CurrentFunctionName= $($PSScriptRoot.split("/")[-1])
}

We need a conditional is as the method is different if you are running local vs in azure.

0

Powered by WordPress. Designed by WooThemes