azlin auth remove¶
Remove authentication profile
Description¶
The azlin auth remove command deletes the specified authentication profile from configuration. This does not affect the actual service principal in Azure - it only removes the azlin configuration.
Usage¶
Arguments¶
| Argument | Description |
|---|---|
PROFILE | Name of the profile to remove (required) |
Options¶
| Option | Type | Description |
|---|---|---|
-y, --yes | Flag | Skip confirmation prompt |
-h, --help | Flag | Show command help and exit |
Examples¶
Remove Profile (With Confirmation)¶
Output:
Remove authentication profile 'old-profile'?
This will delete the stored credentials. [y/N]: y
Removing profile...
✓ Profile 'old-profile' removed successfully
Remove Without Confirmation¶
# Force remove (useful for scripts)
azlin auth remove staging --yes
# Remove multiple profiles
azlin auth remove old-dev --yes
azlin auth remove old-test --yes
azlin auth remove archived --yes
Behavior¶
When you run azlin auth remove PROFILE:
- Validation - Checks that profile exists
- Confirmation - Prompts for confirmation (unless
--yes) - Deletion - Removes profile from config file
- Cleanup - Clears any cached credentials
Note: This does NOT: - Delete the service principal from Azure - Revoke any Azure permissions - Affect other azlin configurations
Common Workflows¶
Clean Up Old Profiles¶
# List profiles
azlin auth list
# Remove unused ones
azlin auth remove old-profile-2023 --yes
azlin auth remove temp-testing --yes
azlin auth remove archived-prod --yes
# Verify cleanup
azlin auth list
Rotate Credentials¶
# Remove old profile
azlin auth remove production --yes
# Create new profile with rotated secret
azlin auth setup production \
--client-id SAME-CLIENT-ID \
--client-secret NEW-SECRET \
--tenant-id SAME-TENANT-ID
# Test new credentials
azlin auth test --profile production
Reset Authentication¶
# Remove all profiles and start fresh
for profile in $(azlin auth list | grep -E "^[a-z]" | awk '{print $1}'); do
azlin auth remove "$profile" --yes
done
# Create new default profile
azlin auth setup default
Safety Features¶
Confirmation Prompt¶
By default, asks for confirmation:
$ azlin auth remove production
Remove authentication profile 'production'?
This will delete the stored credentials. [y/N]:
Type y to proceed, n or Enter to cancel.
Skip Confirmation¶
Use --yes for automation:
Troubleshooting¶
Profile Not Found¶
Symptoms: "Profile 'NAME' not found"
Solutions:
Still Shows After Removal¶
Symptoms: Profile appears after removal
Solutions:
# Check config file directly
cat ~/.azlin/config.toml | grep -A 3 "\[auth\."
# Manually edit if needed
nano ~/.azlin/config.toml
# Or remove config and recreate
mv ~/.azlin/config.toml ~/.azlin/config.toml.backup
azlin auth setup new-profile
Removed Wrong Profile¶
Symptoms: Accidentally deleted needed profile
Solutions:
# Recreate profile (if you have credentials)
azlin auth setup PROFILE-NAME \
--client-id CLIENT-ID \
--client-secret SECRET \
--tenant-id TENANT-ID
# Or restore from backup if you made one
cp ~/.azlin/config.toml.backup ~/.azlin/config.toml
Best Practices¶
Backup Before Removal¶
# Backup config before removing profiles
cp ~/.azlin/config.toml ~/.azlin/config.toml.backup
# Now safe to remove
azlin auth remove old-profile --yes
# If needed, restore
cp ~/.azlin/config.toml.backup ~/.azlin/config.toml
Document Removals¶
# Log profile changes
echo "$(date): Removed profile 'old-prod'" >> ~/.azlin/auth-changes.log
azlin auth remove old-prod --yes
Clean Up Regularly¶
# Monthly profile cleanup
azlin auth list
# Review and remove unused profiles
azlin auth remove unused-1 --yes
azlin auth remove unused-2 --yes
Verify Before Removal¶
# Before removing, verify not in use
azlin auth show profile-name
# Check if any contexts use it
grep -r "profile-name" ~/.azlin/config.toml
# Then safe to remove
azlin auth remove profile-name --yes
Automation Example¶
#!/bin/bash
# Remove old temporary auth profiles
TEMP_PROFILES=$(azlin auth list | grep "temp-" | awk '{print $1}')
for profile in $TEMP_PROFILES; do
echo "Removing $profile..."
azlin auth remove "$profile" --yes
done
echo "Cleanup complete"
azlin auth list
Related Commands¶
azlin auth list- List all profilesazlin auth show- Show profile detailsazlin auth setup- Create profileazlin auth test- Test profile