Benefits of Using Azure KeyVault
Centralized Management
Manage all secrets in one place across multiple repositories
Enhanced Security
Leverage Azure’s security features and access controls
Audit Logging
Track secret access and modifications
Rotation Support
Easily rotate secrets without updating multiple repositories
Prerequisites
Before setting up Azure KeyVault integration:Setup Instructions
1. Connect to Azure
Follow the Azure login action documentation to set up the connection.2. Create Azure_Credentials Secret
Add a compressed JSON construct as a repository secret calledAZURE_CREDENTIALS:
Format:
You can also specify the KeyVault name in the AL-Go settings file instead of including it in the JSON construct.
3. Configure KeyVault Name (Optional)
Alternatively, add the KeyVault name to your settings file: .github/AL-Go-settings.json:Authentication Methods
Managed Identity (Recommended)
Use Azure Managed Identity with federated credentials for the most secure setup: Azure_Credentials:App Registration with Federated Credential
Azure_Credentials:Add Federated Credential
Under Certificates & Secrets, add federated credential for your GitHub repo
App Registration with Client Secret
Azure_Credentials:KeyVault Permissions
Configure permissions based on your KeyVault security model:Role Based Access Control (RBAC) - Recommended
Assign these roles to your managed identity or app registration:| Task | Required Role |
|---|---|
| Read Secrets | Key Vault Secrets User |
| Sign Apps | Key Vault Crypto User + Key Vault Certificate User |
Vault Access Policy
Alternatively, use vault access policies:| Task | Required Permissions |
|---|---|
| Read Secrets | Secret permissions: Get, List |
| Sign Apps | Cryptographic Operations: Sign Certificate permissions: Get |
Storing Secrets in KeyVault
1. Add Secrets to KeyVault
Add your AL-Go secrets to the KeyVault: Example secrets:authContext- For environment deploymentghTokenWorkflow- For updating AL-Go system fileslicenseFileUrl- For Business Central licenseappSourceContext- For AppSource delivery- Any other AL-Go secrets
Enter Details
Name: Secret name (e.g., “authContext”)
Value: Secret value (compressed JSON if applicable)
2. Remove Secrets from GitHub
After adding secrets to KeyVault, remove them from GitHub repository secrets and environment secrets.Testing the Configuration
Test Secret Access
App Signing with KeyVault
To use KeyVault for app signing:1. Import Certificate to KeyVault
Using Azure Portal:2. Configure AL-Go Settings
Add to your.github/AL-Go-settings.json:
3. Verify Permissions
Ensure your identity has:- RBAC: Key Vault Crypto User + Key Vault Certificate User roles
- Access Policy: Cryptographic Operations: Sign + Certificate permissions: Get
Secret Name Mapping
AL-Go looks for secrets in this order:Secret names in KeyVault should match the names AL-Go expects (e.g., “authContext”, “ghTokenWorkflow”). Names are case-insensitive.
Troubleshooting
Secret Not Found
Check secret name
Check secret name
Verify the secret name in KeyVault matches what AL-Go expects
Check permissions
Check permissions
Ensure the identity has “Get” and “List” permissions for secrets
Check Azure_Credentials
Check Azure_Credentials
Verify the Azure_Credentials secret is correctly formatted and contains valid credentials
Check KeyVault name
Check KeyVault name
Ensure the keyVaultName in Azure_Credentials or settings is correct
Authentication Failed
Federated credential
Federated credential
Verify the federated credential is configured for the correct repository, branch, or environment
Client secret expired
Client secret expired
If using client secret, check if it has expired and create a new one
Identity permissions
Identity permissions
Verify the managed identity or app registration has access to the KeyVault
Signing Failed
Premium SKU
Premium SKU
Certificate imported
Certificate imported
Ensure the certificate is properly imported to KeyVault
Signing permissions
Signing permissions
Verify the identity has cryptographic operation permissions
Best Practices
Use Managed Identities
Prefer managed identities with federated credentials for enhanced security
Separate KeyVaults
Use different KeyVaults for development, staging, and production
Enable Logging
Enable diagnostic logging on KeyVault to track secret access
Regular Audits
Regularly review KeyVault access logs and permissions
Least Privilege
Grant only the minimum required permissions
Soft Delete
Enable soft delete and purge protection on KeyVault
Example Complete Configuration
GitHub Secret: Azure_Credentials
KeyVault Secrets
-
authContext
-
ghTokenWorkflow
-
licenseFileUrl
AL-Go Settings (.github/AL-Go-settings.json)
Related Topics
- Secrets Overview - Understanding AL-Go secrets
- GitHub Secrets Reference - Detailed secret documentation
- Advanced Settings - KeyVault-related settings