Skip to content

Commit ee798c4

Browse files
Invoke-DbaDbLogShipping - Pass database-specific Azure URL with explicit base credential
(do Invoke-DbaDbLogShipping)
1 parent 19ed326 commit ee798c4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

public/Invoke-DbaDbLogShipping.ps1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,19 +1483,22 @@ function Invoke-DbaDbLogShipping {
14831483
$Timestamp = Get-Date -format "yyyyMMddHHmmss"
14841484

14851485
if ($UseAzure) {
1486-
# Backup to Azure blob storage - use base URL, put database folder in filename
1486+
# Backup to Azure blob storage - use database-specific URL and explicitly specify credential
14871487
$splatBackup = @{
14881488
SqlInstance = $SourceSqlInstance
14891489
SqlCredential = $SourceSqlCredential
14901490
Database = $($db.Name)
1491-
AzureBaseUrl = $SharedPath
1492-
BackupFileName = "$($db.Name)/FullBackup_$($db.Name)_PreLogShipping_$Timestamp.bak"
1491+
AzureBaseUrl = $DatabaseSharedPath
1492+
BackupFileName = "FullBackup_$($db.Name)_PreLogShipping_$Timestamp.bak"
14931493
Type = "Full"
14941494
}
14951495

1496-
# For Azure credentials, explicitly pass if provided, otherwise let Backup-DbaDatabase auto-detect
1496+
# Explicitly specify Azure credential - use base URL for credential name
14971497
if ($AzureCredential) {
14981498
$splatBackup.AzureCredential = $AzureCredential
1499+
} else {
1500+
# For SAS tokens, credential is named after the base URL
1501+
$splatBackup.AzureCredential = $SharedPath
14991502
}
15001503

15011504
$LastBackup = Backup-DbaDatabase @splatBackup

0 commit comments

Comments
 (0)