async Task <string> CreateVmSettingsString(string region, int vmId, int studyId, int sandboxId, VirtualMachineCreateDto userInput) { var vmSettings = _mapper.Map <VmSettingsDto>(userInput); var availableOs = await _virtualMachineOperatingSystemService.AvailableOperatingSystems(region); vmSettings.OperatingSystemCategory = AzureVmUtil.GetOsCategory(availableOs, vmSettings.OperatingSystem); vmSettings.Password = await StoreNewVmPasswordAsKeyVaultSecretAndReturnReference(studyId, sandboxId, vmSettings.Password); var diagStorageResource = await CloudResourceQueries.GetDiagStorageAccountEntry(_db, sandboxId); vmSettings.DiagnosticStorageAccountName = diagStorageResource.ResourceName; var networkResource = await CloudResourceQueries.GetNetworkEntry(_db, sandboxId); vmSettings.NetworkName = networkResource.ResourceName; var networkSetting = CloudResourceConfigStringSerializer.NetworkSettings(networkResource.ConfigString); vmSettings.SubnetName = networkSetting.SandboxSubnetName; vmSettings.Rules = VmRuleUtils.CreateInitialVmRules(vmId); return(CloudResourceConfigStringSerializer.Serialize(vmSettings)); }
static string CreateVmSettingsString(string size = VirtualMachineConstants.SIZE, string osCategory = "windows", string os = "win2019datacenter") { var vmSettings = new VmSettingsDto() { DiagnosticStorageAccountName = "diagstorageaccountname", NetworkName = "networkName", SubnetName = "subnetname", Size = size, Rules = VmRuleUtils.CreateInitialVmRules(1), OperatingSystemCategory = osCategory, OperatingSystem = os, Username = VirtualMachineConstants.USERNAME, Password = "******", }; return(CloudResourceConfigStringSerializer.Serialize(vmSettings)); }