Introduction
When performing a Point-in-Time Restore (PITR) of an Azure SQL Database, you may need the Database ID to correctly identify the source database. This article outlines the steps to find the SQL Database ID using the Azure Portal, Azure CLI, and Azure PowerShell.
Expected Outcome
After performing a Point-In-Time-Restore the user is able to find the SQL Database ID. The database ID is a required parameter in some automation or scripting scenarios involving PITR.
Prerequisites
-
Make sure the user or service principal performing the action has
Reader
orContributor
access to the resource group containing the database.
Procedure
Option 1: Azure Portal
-
Go to the Azure Portal.
-
Navigate to SQL databases.
-
Click on the target SQL database.
-
In the Overview blade, scroll down and click on JSON View (usually under "Essentials").
-
Look for the
id
field — this is the full Database Resource ID.Example format:
Option 2: Azure CLI
You can retrieve the database ID using the Azure CLI:
This will return the full resource ID string of the database.
Option 3: Azure PowerShell
Run the following command in Azure PowerShell:
This will display the ID property of the specified database.
Additional Information
-
https://learn.microsoft.com/en-us/azure/azure-sql/database/recovery-using-backups