Skip to content

Commit 4575b2b

Browse files
d-bytebaseclaudeh3n4l
authored
docs: improve Azure SQL Managed Identity authentication documentation (#838)
* docs: improve Azure SQL Managed Identity authentication documentation - Renamed section from "Entra Managed Identity" to "Azure SQL with Managed Identity Authentication" for clarity - Restructured content to follow the same secure pattern as AWS and GCP sections - Emphasized VM-attached managed identity approach as the most secure method - Added comprehensive Azure documentation references throughout - Included security best practices and production recommendations - Removed screenshots in favor of text instructions with official documentation links - Added step-by-step configuration with proper SQL permission examples - Clarified that no credentials (AZURE_TENANT_ID, AZURE_CLIENT_SECRET) are needed with managed identities - Added alternative user-assigned managed identity configuration - Improved readability with consistent formatting and structure 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Update mintlify/get-started/instance.mdx --------- Co-authored-by: Claude <[email protected]> Co-authored-by: h3n4l <[email protected]>
1 parent 39e79fc commit 4575b2b

File tree

4 files changed

+85
-21
lines changed

4 files changed

+85
-21
lines changed

mintlify/get-started/instance.mdx

Lines changed: 85 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -448,42 +448,106 @@ Go to instance setting, specify the fully qualified name such as `projects/22871
448448

449449
## Azure Configuration
450450

451-
### Entra Managed Identity
451+
### Azure SQL with Managed Identity Authentication
452452

453-
Bytebase supports connect to Azure SQL through Azure IAM by using default Azure credential and client secret credential. This section introduces how to use [system-assigned managed identity](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview#managed-identity-types) to connect to Azure SQL.
454-
For more information about the credential chain in default Azure credential, please refer to [default azure credential overview](https://learn.microsoft.com/en-us/azure/developer/go/sdk/authentication/credential-chains#how-a-chained-credential-works).
453+
This guide demonstrates the most secure method for connecting to Azure SQL Database and Azure SQL Managed Instance using VM-attached managed identities, eliminating the need to manage credentials or connection strings.
455454

456-
#### Create a VM with enabled system-assigned managed identity
455+
For alternative authentication methods and detailed configuration options, refer to:
456+
- [Azure SQL authentication methods overview](https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-overview)
457+
- [Managed identities for Azure resources](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview)
458+
- [Configure Azure AD authentication for SQL Database](https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-configure)
459+
- [Connect to Azure SQL with managed identity](https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-azure-ad-user-assigned-managed-identity)
457460

458-
1. Enable system assigned managed identity while creating a VM.
459-
![](/content/docs/get-started/instance/azure-iam/enable-system-assigned-managed-identity-while-creating-vm.webp)
461+
#### Step 1: Create Azure VM with System-Assigned Managed Identity
460462

461-
2. Deploy the Bytebase on the VM in Docker.
462-
463-
#### Enable Microsoft Entra Authentication in Azure SQL
464-
465-
1. Go to the Azure SQL panel, and set the Microsoft Entra Admin for Azure SQL managed instance, don't forget to click Save button. Once you set the Microsoft Entra Admin, the Microsoft Entra authentication is enabled. Check the [Microsoft guide](https://learn.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/configure-azure-ad-authentication-for-sql-vm?view=azuresql&tabs=azure-portal) if you use Azure SQL on VM.
463+
1. **Create VM with Managed Identity**
464+
- Go to [Azure Portal → Virtual Machines](https://portal.azure.com/#blade/HubsExtension/BrowseResource/resourceType/Microsoft.Compute%2FVirtualMachines)
465+
- Click **Create****Azure virtual machine**
466+
- Configure VM settings as needed
467+
- Under **Management** tab:
468+
- Enable **System assigned managed identity**: Set to **On**
469+
- Complete VM creation
470+
471+
> **Security Best Practice:** System-assigned managed identities are automatically managed by Azure and tied to the VM lifecycle. This eliminates credential management and reduces security risks. Learn more: [Managed identity best practices](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/managed-identity-best-practice-recommendations)
466472
467-
![](/content/docs/get-started/instance/azure-iam/set-microsoft-entra-admin-in-azure-sql-panel.webp)
473+
2. **Deploy Bytebase on the VM**
474+
475+
Deploy Bytebase on your Azure VM. The VM's managed identity is automatically available - no credential configuration needed.
468476

469-
#### Create a contained database user
477+
#### Step 2: Configure Azure SQL Database
470478

471-
1. Connect to the Azure SQL database using the Microsoft Entra Admin account.
479+
1. **Enable Microsoft Entra Authentication**
480+
- Navigate to your Azure SQL Server in [Azure Portal](https://portal.azure.com)
481+
- Go to **Settings****Microsoft Entra ID**
482+
- Click **Set admin** and select an Entra admin account
483+
- Click **Save** to enable Entra authentication
484+
485+
Reference: [Configure Entra authentication for Azure SQL](https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-configure)
472486

473-
2. For each databases desired to be managed by Bytebase, running the following SQL command inside the database to create a contained database user:
487+
2. **Grant Database Access to Managed Identity**
488+
- Note your VM's managed identity name (same as VM name)
489+
- Connect to Azure SQL using the Entra admin account
490+
- Run the following for each database:
474491

475492
```sql
476-
CREATE USER [<Microsoft_Entra_principal_name>] FROM EXTERNAL PROVIDER;
477-
ALTER ROLE db_owner ADD MEMBER [<Microsoft_Entra_principal_name>];
493+
-- Create user for the VM's managed identity
494+
CREATE USER [your-vm-name] FROM EXTERNAL PROVIDER;
495+
496+
-- Grant appropriate permissions (adjust as needed)
497+
ALTER ROLE db_datareader ADD MEMBER [your-vm-name];
498+
ALTER ROLE db_datawriter ADD MEMBER [your-vm-name];
499+
ALTER ROLE db_ddladmin ADD MEMBER [your-vm-name];
500+
501+
-- For full database management in Bytebase:
502+
ALTER ROLE db_owner ADD MEMBER [your-vm-name];
478503
```
504+
505+
> **Production Best Practice:** Follow the principle of least privilege. Grant only the minimum permissions required for your use case. See [Azure SQL Database permissions](https://learn.microsoft.com/en-us/azure/azure-sql/database/logins-create-manage).
506+
507+
#### Step 3: Connect from Bytebase
479508

480-
#### Connect to Azure SQL Database in Bytebase
509+
1. Access Bytebase on your VM (typically `http://localhost:5678`)
510+
2. Click **New Instance**
511+
3. Configure the connection:
512+
- **Host:** Your Azure SQL server name (e.g., `yourserver.database.windows.net`)
513+
- **Port:** 1433
514+
- **Database:** Target database name
515+
- **Authentication:** Select `Azure Default Credential`
516+
4. Test and save the connection
481517

482-
1. Using Azure IAM default credential to connect to Azure SQL database:
518+
Bytebase automatically uses the VM's managed identity through Azure's Instance Metadata Service (IMDS) for authentication.
483519

484-
![](/content/docs/get-started/instance/azure-iam/connect-to-azure-sql-using-azure-iam-frontend-form.webp)
520+
<Tip>
521+
**Advantages of this approach:**
522+
- No passwords or connection strings to manage
523+
- Automatic credential rotation handled by Azure
524+
- Enhanced security through Azure RBAC
525+
- Simplified compliance and auditing
526+
527+
For troubleshooting, see [Troubleshoot managed identity authentication](https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-azure-ad-user-assigned-managed-identity#troubleshooting).
528+
</Tip>
529+
530+
#### Alternative: User-Assigned Managed Identity
531+
532+
For more granular control or cross-resource scenarios:
533+
534+
1. **Create User-Assigned Managed Identity**
535+
- Go to [Managed Identities](https://portal.azure.com/#blade/HubsExtension/BrowseResource/resourceType/Microsoft.ManagedIdentity%2FuserAssignedIdentities)
536+
- Create a new identity with a descriptive name
537+
- Assign it to your VM under **Settings****Identity****User assigned**
538+
539+
2. **Configure Database Access**
540+
```sql
541+
CREATE USER [managed-identity-name] FROM EXTERNAL PROVIDER;
542+
ALTER ROLE db_owner ADD MEMBER [managed-identity-name];
543+
```
544+
545+
3. **Set Environment Variable** (if using multiple identities)
546+
```bash
547+
export AZURE_CLIENT_ID=<managed-identity-client-id>
548+
```
485549

486-
In this way, Bytebase can only connect to one specific Azure SQL database. To manage multiple Azure SQL databases in one instance inside Bytebase, considering set the VM principal as the Azure SQL Managed Instance Microsoft Entra Admin.
550+
Reference: [User-assigned managed identities](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities)
487551

488552
## Database-Specific Guides
489553

0 commit comments

Comments
 (0)