Bird
Raised Fist0
Azurecloud~10 mins

Database backup and geo-replication in Azure - Interactive Code Practice

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create an Azure SQL database with geo-replication enabled.

Azure
az sql db create --resource-group myResourceGroup --server myServer --name myDatabase --service-objective [1]
Drag options to blanks, or click blank then click option'
AS0
BGP_Gen5_2
CBasic
DPremium
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing Basic or S0 which do not support geo-replication.
Using Premium which is more expensive but not required here.
2fill in blank
medium

Complete the command to create a readable secondary database in a different region for geo-replication.

Azure
az sql db replica create --name myDatabaseSecondary --resource-group myResourceGroup --server myServerSecondary --partner-server [1] --read-only-routing-url https://myserversecondary.database.windows.net
Drag options to blanks, or click blank then click option'
AmyServer
BmyServerSecondary
CmyDatabase
DmyResourceGroup
Attempts:
3 left
💡 Hint
Common Mistakes
Using the secondary server name as partner-server.
Using the database name instead of server name.
3fill in blank
hard

Fix the error in the command to enable geo-backup retention for 14 days.

Azure
az sql db backup [1] --resource-group myResourceGroup --server myServer --database myDatabase --retention-days 14
Drag options to blanks, or click blank then click option'
Aset
Bconfigure
Cupdate
Dpolicy
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set' or 'update' which are invalid in this context.
Using 'configure' which is not a valid subcommand.
4fill in blank
hard

Fill both blanks to configure geo-replication failover group with automatic failover policy and grace period.

Azure
az sql failover-group create --name myFailoverGroup --resource-group myResourceGroup --server myServerPrimary --partner-server myServerSecondary --failover-policy [1] --grace-period [2]
Drag options to blanks, or click blank then click option'
AAutomatic
BManual
C1 hour
D0 minutes
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing manual failover policy which requires manual intervention.
Setting grace period to 0 minutes which can cause immediate failover.
5fill in blank
hard

Fill all three blanks to create a geo-replication link, set backup retention to 7 days, and enable zone redundancy.

Azure
az sql db replica create --name myReplica --resource-group myResourceGroup --server myServerSecondary --partner-server [1] --backup-retention [2] --zone-redundant [3]
Drag options to blanks, or click blank then click option'
AmyServerPrimary
B7
Ctrue
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using secondary server as partner-server.
Setting backup retention to 0 or invalid values.
Disabling zone redundancy when it is required.

Practice

(1/5)
1. What is the main purpose of geo-replication in Azure SQL Database?
easy
A. To increase the database query speed
B. To compress the database backup files
C. To encrypt the database data at rest
D. To copy the database to another region for high availability

Solution

  1. Step 1: Understand geo-replication concept

    Geo-replication copies your database to a different geographic region to ensure availability if one region fails.
  2. Step 2: Compare options with geo-replication purpose

    Options B, C, and D describe backup compression, encryption, and performance, which are unrelated to geo-replication.
  3. Final Answer:

    To copy the database to another region for high availability -> Option D
  4. Quick Check:

    Geo-replication = High availability by copying database [OK]
Hint: Geo-replication means copying data to another region [OK]
Common Mistakes:
  • Confusing geo-replication with backup compression
  • Thinking geo-replication improves query speed
  • Mixing encryption with replication
2. Which Azure CLI command is used to create a geo-replica of an existing Azure SQL Database named mydb in the eastus2 region?
easy
A. az sql db replica create --name mydb --resource-group mygroup --server myserver --partner-server eastus2server
B. az sql db replica create --name mydb --resource-group mygroup --server myserver --partner-server eastus2
C. az sql db replica create --name mydb --resource-group mygroup --server myserver --partner-server eastus2server --location eastus2
D. az sql db replica create --name mydb --resource-group mygroup --server myserver --partner-server eastus2server --geo-location eastus2

Solution

  1. Step 1: Identify correct Azure CLI syntax for geo-replica

    The command az sql db replica create requires the partner server name, not just the region name.
  2. Step 2: Analyze options for correct partner-server parameter

    az sql db replica create --name mydb --resource-group mygroup --server myserver --partner-server eastus2server uses eastus2server as partner-server, which is the correct server name format. az sql db replica create --name mydb --resource-group mygroup --server myserver --partner-server eastus2 uses region name incorrectly, A and D add unsupported parameters.
  3. Final Answer:

    az sql db replica create --name mydb --resource-group mygroup --server myserver --partner-server eastus2server -> Option A
  4. Quick Check:

    Partner server must be server name, not region [OK]
Hint: Partner server must be server name, not region name [OK]
Common Mistakes:
  • Using region name instead of partner server name
  • Adding unsupported parameters like --geo-location
  • Confusing resource group with server name
3. Given this Azure CLI command output snippet after creating a geo-replica:
{
  "name": "mydb-replica",
  "location": "eastus2",
  "status": "Online",
  "replicationRole": "Secondary"
}
What does the replicationRole value indicate?
medium
A. The database is the primary writable copy
B. The database backup is in progress
C. The database is a read-only secondary replica
D. The database is offline and not replicating

Solution

  1. Step 1: Understand replicationRole meaning

    In Azure SQL geo-replication, 'Secondary' means the database is a read-only copy that replicates changes from the primary.
  2. Step 2: Match status with replicationRole

    Status 'Online' confirms the replica is active and available for read-only queries, not offline or backup state.
  3. Final Answer:

    The database is a read-only secondary replica -> Option C
  4. Quick Check:

    replicationRole 'Secondary' = read-only replica [OK]
Hint: Secondary role means read-only replica [OK]
Common Mistakes:
  • Thinking 'Secondary' means primary writable copy
  • Confusing backup status with replication role
  • Assuming 'Secondary' means offline
4. You tried to create a geo-replica using this command:
az sql db replica create --name mydb --resource-group mygroup --server myserver --partner-server eastus2
But you get an error saying partner server not found. What is the likely cause?
medium
A. The partner server name is incorrect; it should be the server's actual name, not the region
B. The resource group name is invalid
C. The database name is missing
D. Geo-replication is not supported in eastus2 region

Solution

  1. Step 1: Check partner-server parameter usage

    The partner-server parameter requires the actual server name, not the region name like 'eastus2'.
  2. Step 2: Verify error cause

    Using 'eastus2' as partner-server causes the 'not found' error because Azure expects a server name, e.g., 'myserver-eastus2'.
  3. Final Answer:

    The partner server name is incorrect; it should be the server's actual name, not the region -> Option A
  4. Quick Check:

    Partner server must be server name, not region [OK]
Hint: Partner server must be server name, not region [OK]
Common Mistakes:
  • Using region name instead of server name
  • Assuming resource group or database name causes this error
  • Believing geo-replication is unsupported in common regions
5. You want to ensure your Azure SQL Database backups are geo-redundant and can be restored in a different region if the primary region fails. Which backup configuration should you choose?
hard
A. Use Locally Redundant Storage (LRS) for faster backups
B. Use Geo-Redundant Backup (GRS) storage for automated backups
C. Manually copy backups to another region using Azure Storage Explorer
D. Disable automated backups and create manual backups only

Solution

  1. Step 1: Understand backup redundancy options

    Geo-Redundant Storage (GRS) replicates backups to a secondary region automatically, ensuring recovery if primary region fails.
  2. Step 2: Compare options for geo-redundancy

    LRS stores backups only in one region, manual copying is error-prone, and disabling automated backups risks data loss.
  3. Final Answer:

    Use Geo-Redundant Backup (GRS) storage for automated backups -> Option B
  4. Quick Check:

    Geo-redundant backups = automatic cross-region backup [OK]
Hint: Choose Geo-Redundant Storage for cross-region backup safety [OK]
Common Mistakes:
  • Choosing LRS which stores backups only locally
  • Relying on manual backup copies
  • Disabling automated backups risking data loss