我想在一個雲服務中添加多個虛擬機。一個天青雲服務中具有不同網址的多個虛擬機?
現在,我可以在此雲服務中創建一個雲服務和一個虛擬機。在此之後,我試圖在同一個部署中將另一個虛擬機添加到相同的sloud服務中,並且此過程也是成功的,但我無法理解的是如何爲此新虛擬機設置不同的url!?
因爲現在,第一臺虛擬機的網址是myservicename.cloudapp.net,而第二臺虛擬機的網址是一樣的!他們有相同的IP。怎麼會這樣?當它具有相同的URL時,如何訪問第二臺虛擬機?
端口爲第一VM是:80,和第二VM是81
問題:
如何存取權限單個虛擬機?
有沒有一種方法來使網址的像:myservicename.vmname.cloudapp.net? 使第一VM網址爲:myservicename.vmname1.cloudapp.net和URL爲第二機器:myservicename.vmname2.cloudapp.net
代碼:
私人異步任務CreateVirtualMachine() { DeploymentGetResponse deploymentResponse =等待_computeManagementClient.Deployments.GetBySlotAsync(「myservicename」,DeploymentSlot.Production);
if (deploymentResponse == null)
{
var parameters = new VirtualMachineCreateDeploymentParameters
{
DeploymentSlot = DeploymentSlot.Production,
Name = "mservicename",
Label = "myservicename"
};
parameters.Roles.Add(new Role
{
OSVirtualHardDisk = new OSVirtualHardDisk
{
HostCaching = VirtualHardDiskHostCaching.ReadWrite,
SourceImageName = "imagename"
},
RoleName = "vmname",
RoleType = VirtualMachineRoleType.PersistentVMRole.ToString(),
RoleSize = VirtualMachineRoleSize.Small,
ProvisionGuestAgent = true
});
parameters.Roles[0].ConfigurationSets.Add(new ConfigurationSet
{
ComputerName = "vmname",
ConfigurationSetType = ConfigurationSetTypes.LinuxProvisioningConfiguration,
HostName = "vmname",
AdminUserName = "adminusername",
AdminPassword = "adminpass",
UserName = "username",
UserPassword = "userpass",
DisableSshPasswordAuthentication = false,
});
parameters.Roles[0].ConfigurationSets.Add(new ConfigurationSet
{
ConfigurationSetType = ConfigurationSetTypes.NetworkConfiguration,
InputEndpoints = new List<InputEndpoint>()
{
new InputEndpoint()
{
Name = "HTTP",
Protocol = InputEndpointTransportProtocol.Tcp,
LocalPort = 80,
Port = 80
}
}
});
var response = await _computeManagementClient.VirtualMachines.CreateDeploymentAsync("mservicename", parameters);
}
else
{
var createParameters = new VirtualMachineCreateParameters
{
OSVirtualHardDisk = new OSVirtualHardDisk
{
HostCaching = VirtualHardDiskHostCaching.ReadWrite,
SourceImageName = "imagename"
},
RoleName = "vmname",
RoleSize = VirtualMachineRoleSize.Small,
ProvisionGuestAgent = true,
ConfigurationSets = new List<ConfigurationSet>
{
new ConfigurationSet
{
ComputerName = "vmname",
ConfigurationSetType = ConfigurationSetTypes.LinuxProvisioningConfiguration,
HostName = "vmname",
AdminUserName = "adminusername",
AdminPassword = "adminpass",
UserName = "username",
UserPassword = "userpass",
DisableSshPasswordAuthentication = false
},
new ConfigurationSet
{
ConfigurationSetType = ConfigurationSetTypes.NetworkConfiguration,
InputEndpoints = new List<InputEndpoint>()
{
new InputEndpoint()
{
Name = "HTTP",
Protocol = InputEndpointTransportProtocol.Tcp,
LocalPort = 81,
Port = 81
}
}
}
}
};
var responseCreate = await _computeManagementClient.VirtualMachines.CreateAsync("mservicename", deploymentResponse.Name, createParameters);
}
}
謝謝你的回答。 – gomila
@gomila第一:你應該考慮一個「upvote」和/或接受一個答案是正確的方式說「謝謝」 - 而不是一個評論。第二:請不要在編輯中提出其他問題。問另一個問題。三:這些問題真的是針對ServerFault,而不是StackOverflow。四:根據您的編輯,我認爲您有一些術語混淆(例如,存儲帳戶與VM限制無關)。 –