Skip to content

sql registration fix #27772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ public void RegisterContainer()
string containerName = (string)ProviderData[ContainerParams.Name];
string backupManagementType = (string)ProviderData[ContainerParams.BackupManagementType];
string workloadType = (string)ProviderData[ContainerParams.ContainerType];
string vmResourceGroupName = (string)ProviderData[ContainerParams.ResourceGroupName];
ContainerBase containerBase =
(ContainerBase)ProviderData[ContainerParams.Container];
AzureVmWorkloadContainer container = (AzureVmWorkloadContainer)ProviderData[ContainerParams.Container];
Expand All @@ -985,8 +986,14 @@ public void RegisterContainer()
List<ProtectableContainerResource> unregisteredVmContainers =
GetUnRegisteredVmContainers(vaultName, vaultResourceGroupName);
ProtectableContainerResource unregisteredVmContainer = unregisteredVmContainers.Find(
vmContainer => string.Compare(vmContainer.Name.Split(';').Last(),
containerName, true) == 0);
vmContainer => {
string[] containerNameSplit = vmContainer.Name.Split(';');
int containerNameSplitLen = containerNameSplit.Length;
bool vmNameMatch = string.Compare(containerNameSplit[containerNameSplitLen - 1], containerName, true) == 0;
bool rgNameMatch = string.Compare(containerNameSplit[containerNameSplitLen - 2], vmResourceGroupName, true) == 0;

return vmNameMatch && rgNameMatch;
});

if (unregisteredVmContainer != null || container != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public override void ExecuteCmdlet()
ResourceIdentifier resourceIdentifier = new ResourceIdentifier(VaultId);
string vaultName = resourceIdentifier.ResourceName;
string vaultResourceGroupName = resourceIdentifier.ResourceGroupName;
string vmResourceGroupName = Container != null ? Container.Name : ResourceId.Split('/')[4];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. why are we initializing the vmResourceGroupName = container.Name ?
  2. )[4] - we shouldn't use the index, we have common funtion to extract resourcegroupname from ARMIDs in general.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corrected, using vault rg name by default now


PsBackupProviderManager providerManager =
new PsBackupProviderManager(new Dictionary<Enum, object>()
Expand All @@ -110,7 +111,8 @@ public override void ExecuteCmdlet()
{ ContainerParams.Name, containerName },
{ ContainerParams.ContainerType, ServiceClientHelpers.GetServiceClientWorkloadType(WorkloadType).ToString() },
{ ContainerParams.BackupManagementType, BackupManagementType.ToString() },
{ ContainerParams.Container, Container}
{ ContainerParams.Container, Container},
{ ContainerParams.ResourceGroupName, vmResourceGroupName },
}, ServiceClientAdapter);

IPsBackupProvider psBackupProvider =
Expand Down