Azure / Azure/azure-powershell
Restore-AzCosmosDBAccount cannot restore from deleted CosmosDB Account anymore
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
### Description
In the version **Az.CosmosDB 1.10.0 or above** the Restore-AzCosmosDBAccount does not allow restore from deleted CosmosDB Accounts (except the oldest one). There is a warning "**No database accounts found with matching account name cosmos-aa-bb-cc that was alive at given utc-timestamp"**. In version **1.9.0 it works with no issue**. In both cases Get-AzCosmosDBRestorableDatabaseAccount displays the current and also all the deleted CosmosDB Accounts. It has been tested with multiple CosmosDB Accounts.
```
Id : /subscriptions/xx/providers/Microsoft.DocumentDB/locations/centralus/restorableDatabaseAccounts/xx
DatabaseAccountInstanceId : xxx
Location : Central US
DatabaseAccountName : cosmos-aa-bb-cc
CreationTime : 5/14/2024 8:20:15 AM
DeletionTime : 5/15/2024 4:24:02 PM
OldestRestorableTime : 4/15/2024 5:10:32 PM
ApiType : Sql
RestorableLocations : {Central US}
Starting restore process for cosmos-aa-gl-bb...
Initiating restore operation for CosmosDB Account 'cosmos-aa-bb-cc'...
WARNING: No database accounts found with matching account name cosmos-aa-bb-cc that was alive at given utc-timestamp 5/15/2024 12:40:34 PM in location Central US
```
### Issue script & Debug output
```PowerShell
$RestoredDatabaseAccount = Restore-AzCosmosDBAccount `
-TargetResourceGroupName $ResourceGroupName `
-TargetDatabaseAccountName $DatabaseAccountName `
-SourceDatabaseAccountName $DatabaseAccountName `
-RestoreTimestampInUtc $RestorePoint `
-Location $RestorableDatabaseAccount.Location `
```
### Environment data
```PowerShell
Name Value
---- -----
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
### Module versions
```PowerShell
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 3.0.0 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script 1.14.3 Az.CosmosDB {Get-AzCosmosDBAccount, Get-AzCosmosDBAccountKey, Get-AzCosmosDBCassandraKeyspace, Get-AzCosmosDBCassandraKeyspaceThroughput…}
```
### Error output
```PowerShell
WARNING: No database accounts found with matching account name cosmos-aa-bb-cc that was alive at given utc-timestamp 5/15/2024 12:40:34 PM in location Central US
Restoration failed
```
Contributor guide
Research direction
Start at the Restore-AzCosmosDBAccount entry point and reproduce the warning with a deleted Cosmos DB account using the script and module versions in the report. Compare behavior between Az.CosmosDB 1.9.0 and 1.10.0 or later; done means restoring a deleted account at the specified UTC timestamp succeeds rather than reporting no matching account.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, powershell
- Domain
- cli, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100