azurefunctionvisual-studio-codeazure-service-principal

How to sign in VS Code Azure Function extension with a service principal (clientid and secret)


How to sign in to the VS Code Azure Function extension with a service principal (client ID and secret)?

enter image description here

I don't have contribute access to my account and would like to use my service principal to contribute.


Solution

  • You can't sign in VS Code Azure Function extension with a service principal.

    You must use the CLI command below to Sign in with the Service Principal.

    az login --service-principal -u <app-id> -p <password-or-cert> --tenant <tenant>
    
    az account set --subscription "subscription_name"
    

    Output :

    enter image description here

    This will not set your Azure account with service principal id and when you use DefaultAzureCredentials or try to deploy function app it will deploy it with this account.

    Try deploying your function with this command in your CLI:-

    func azure functionapp publish <APP_NAME>
    

    Reference :

    Check this MS Doc to Sign in with the Service Principal.