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 3 commits
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 @@ -12,6 +12,7 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Compute;
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel;
using Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers;
Expand Down Expand Up @@ -97,10 +98,12 @@ public override void ExecuteCmdlet()
containerName, () =>
{
base.ExecuteCmdlet();
string vmResourceGroupParsed = ARMStorageService.ParseResourceGroupFromId(ResourceId);

ResourceIdentifier resourceIdentifier = new ResourceIdentifier(VaultId);
string vaultName = resourceIdentifier.ResourceName;
string vaultResourceGroupName = resourceIdentifier.ResourceGroupName;
string vmResourceGroupName = Container != null ? vaultResourceGroupName : vmResourceGroupParsed;

PsBackupProviderManager providerManager =
new PsBackupProviderManager(new Dictionary<Enum, object>()
Expand All @@ -110,7 +113,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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Compute\Compute\Compute.csproj" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't reference csproject of other modules in your non-test csproject. You can refer package directly

<ProjectReference Include="..\RecoveryServices.Management.Sdk\RecoveryServices.Management.Sdk.csproj" />
<ProjectReference Include="..\RecoveryServices.Backup.Management.Sdk\RecoveryServices.Backup.Management.Sdk.csproj" />
<ProjectReference Include="..\RecoveryServices.Backup.CrossRegionRestore.Management.Sdk\RecoveryServices.Backup.CrossRegionRestore.Management.Sdk.csproj" />
Expand Down
Loading