Is it possible to show if OAuth is being used for Azure Function App?

54 Views Asked by At

I am currently trying to use the Azure CLI to list the Function Apps and segregate them based on the security they are set up with. If the app is set up with "Client Certificates" mechanism then it is being listed using the "az cli" functionapp commands. But, unable to figure out how to determine if the function app is secured with "OAuth" mechanism or not.

Is this something that is not directly available using the functionapp commands?

2

There are 2 best solutions below

1
LearnTech On

To determine if an Azure Function App is secured with OAuth, you can use the Azure CLI command az functionapp auth show which will show the authentication settings for the function app. If OAuth is being used, it will be listed under the "Enabled Providers" section.

Here's an example command to list the authentication settings for a specific function app:

az functionapp auth show --name <function-app-name> --resource-group <resource-group-name>

If OAuth is being used, it will be listed under the "Enabled Providers" section.

Check below Ref.

Authentication types by deployment methods in Azure App Service

Azure CLI conceptual article list (ref-zone3)

0
user2794745 On

You can check if Authorization is enabled by checking if Enabled is True for the following output:

az webapp auth show --name <app-name> --resource-group <resource-group>

This works for both Web Apps and Function Apps.

If you want to loop through all the App Services in a particular Resource Group:

$webapps = az webapp list -g <resource-group> | ConvertFrom-Json

foreach ($webapp in $webapps)
{
    $auth = az webapp auth show --name $webapp.name --resource-group <resource-group> | ConvertFrom-Json

    if ($auth.enabled)
    {
        $webAppName = $webapp.name
        $resourceGroupName = $webapp.resourceGroup
        $location = $webapp.location

        "--------------------------------------------------------------------"
        "WebApp: " + $webAppName + "      ResourceGroup: " + $webapp.resourceGroup + "      Location: " + $webapp.location
        
        "AllowedAudiences: " + $auth.allowedAudiences
        "ClientId: " + $auth.clientId
        "ConfigVersion: " + $auth.configVersion
        "Enabled: " + $auth.enabled
        "IsAuthFromFile: " + $auth.isAuthFromFile
        "Issuer: " + $auth.issuer
        "Name: " + $auth.name
        "RuntimeVersion: " + $auth.runtimeVersion
        "TokenStoreEnabled: " + $auth.tokenStoreEnabled
        "UnauthenticatedClientAction: " + $auth.unauthenticatedClientAction
    }
}