Install
No framework information available.
README
azdbr
Azure SQL Database Refresh .NET global tool. Safely refresh a staging or development Azure SQL database from production within the same Microsoft Entra tenant.
Install
dotnet tool install -g azdbr
Usage
azdbr refresh <source-server> <source-database> <target-server> <target-database>
Example:
azdbr refresh prod-server prod-db staging staging-db
azdbr refresh prod-server prod-db staging staging-db --dry-run
azdbr refresh prod-server prod-db staging staging-db -y --service-objective S2
azdbr refresh prod-server prod-db staging staging-db --keep-old-database
Options
| Option | Description |
|---|---|
--tenant-id |
Optional Microsoft Entra tenant id for authentication |
--service-objective |
Optional service objective for the copied database |
--backup-storage-redundancy |
Optional redundancy: LOCAL, ZONE, GEO, GEOZONE |
--keep-old-database |
Keep the renamed old database after success |
--dry-run |
Run preflight and print planned steps only |
-y, --yes |
Skip interactive confirmation |
--command-timeout-minutes |
SQL command timeout for non-copy operations (default: 30) |
--copy-timeout-minutes |
Maximum wait time for copy completion (default: 240) |
What it does
- Validates that the target database exists and no leftover
*-olddatabase remains - Kills active user sessions on the target database
- Renames the target database to
<target-database>-old - Verifies the target database name is free
- Creates a new database with
CREATE DATABASE ... AS COPY OF - Fixes orphaned login-based users
- Syncs staging-only roles, users, and role memberships from the old database
- Drops the old database by default
Permissions
The identity running azdbr must:
- Authenticate with Microsoft Entra ID via
DefaultAzureCredential - Be a member of
dbmanagerinmasteron both source and target servers - Have
db_owneron the source database
See Copy a database in Azure SQL Database for platform details.
Limitations
- Same Microsoft Entra tenant only in v1
- Cross-tenant copy requires SQL authentication and is not supported by this tool
- Database copy over a private endpoint to the destination server is not supported by Azure SQL T-SQL copy
- Both server firewalls must allow the machine running
azdbr
Build and test
dotnet cake.cs
This runs restore, build, test, pack, and tool integration tests (azdbr --help).
Integration tests
The Cake pipeline installs the packed tool locally and runs:
azdbr --help(always)azdbr refresh ... -yagainst real Azure SQL when integration secrets are configured
Set these environment variables (or GitHub Actions secrets) to enable the Azure SQL integration test:
| Variable | Description |
|---|---|
AZDBR_INTEGRATION_SOURCE_SERVER |
Source logical server |
AZDBR_INTEGRATION_SOURCE_DATABASE |
Source database |
AZDBR_INTEGRATION_TARGET_SERVER |
Target logical server |
AZDBR_INTEGRATION_TARGET_DATABASE |
Target database (must exist) |
AZDBR_INTEGRATION_TENANT_ID |
Optional Entra tenant for the refresh |
AZURE_TENANT_ID |
Service principal tenant (CI) |
AZURE_CLIENT_ID |
Service principal client id (CI) |
AZURE_CLIENT_SECRET |
Service principal secret (CI) |
Locally, the Azure refresh test runs when the four AZDBR_INTEGRATION_* server/database variables are set and you are authenticated via az login / DefaultAzureCredential. In CI, the same four variables plus Azure service principal credentials are required.
License
MIT
Changes from Previous Version
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.