[SQL Migration] Add storage/VM connectivity validation (#22982)

* Implement storage account connectivity check for SQL VM targets

* Add missing break statement

* Address PR comments
This commit is contained in:
Raymond Truong
2023-05-08 11:42:40 -04:00
committed by GitHub
parent 3ae97b81f2
commit 6684dbb78c
3 changed files with 23 additions and 9 deletions

View File

@@ -571,8 +571,18 @@ export async function canTargetConnectToStorageAccount(
break;
case MigrationTargetType.SQLVM:
// to-do: VM scenario -- get subnet by first checking underlying compute VM, then its network interface
return true;
const targetVmNetworkInterfaces = Array.from((await NetworkInterfaceModel.getVmNetworkInterfaces(account, subscription, (targetServer as SqlVMServer))).values());
const targetVmSubnets = targetVmNetworkInterfaces.map(networkInterface => {
const ipConfigurations = networkInterface.properties.ipConfigurations ?? [];
return ipConfigurations.map(ipConfiguration => ipConfiguration.properties.subnet.id.toLowerCase());
}).flat();
// 2) check for access from whitelisted vnet
if (storageAccountWhitelistedVNets.length > 0) {
enabledFromWhitelistedVNet = storageAccountWhitelistedVNets.some(vnet => targetVmSubnets.some(targetVnet => vnet.toLowerCase() === targetVnet.toLowerCase()));
}
break;
default:
return true;
}