How to logout Azure from swa-cli?

565 Views Asked by At

Azure SWA offer swa login command. What if I want to logout Azure account. What can I do? There is no swa logout command by default.

2

There are 2 best solutions below

0
On

It because I use Windows 10. Here are the commands we need to clear credentials.

Find all credential created by swa-cli

cmdkey.exe /list | findstr swa-cli

Clear all credential created by swa-cli

cmdkey.exe /list | findstr swa-cli | ForEach-Object {
  cmdkey /delete:$($_.Split(' ')[5])
}
0
On

As of v1.1.4, there's a --clear-credentials command-line option:

$ npx @azure/static-web-apps-cli login --help

Welcome to Azure Static Web Apps CLI (1.1.4)

Usage: swa login [options]

login into Azure

Options:
  -S, --subscription-id <subscriptionId>  Azure subscription ID used by this project (default: "...")
  -R, --resource-group <resourceGroup>    Azure resource group used by this project
  -T, --tenant-id <tenantId>              Azure tenant ID (default: "...")
  -C, --client-id <clientId>              Azure client ID
  -CS, --client-secret <clientSecret>     Azure client secret
  -n, --app-name <appName>                Azure Static Web App application name
           
  -CC, --clear-credentials                clear persisted credentials before login (default: false)

So you could run:

npx @azure/static-web-apps-cli login --clear-credentials

or:

npx @azure/static-web-apps-cli login -CC