examples
examples copied to clipboard
vSphere VirtualMachine dotnet example
Can you please add an example on how to create a simple virtual machine using vSphere?
That would allow new users to quickly get the gist of how things work with pulumi/dotnet/vSphere.
The example should show how to create a simple VM:
- cloned from an existing VM template name
- inside an existing Datacenter/Cluster/ComputeResource given by name
- have a single network interface connected to the given network name
FWIW, I'm trying to make an equivalent of https://github.com/rgl/terraform-rke-vsphere-cloud-provider-example, but got stuck trying to get an existing network. For example, to get an existing Datacenter its a simple:
var datacenterName = Environment.GetEnvironmentVariable("VSPHERE_DATACENTER");
var datacenter = Datacenter.Get(
"datacenter",
"/" + datacenterName
);
But getting the network seems the be a whole different endeavor.
It seems a simple Network.Get does not exist. Instead, I only found https://github.com/pulumi/pulumi-vsphere/blob/v4.0.1/sdk/dotnet/GetNetwork.cs#L33-L41 which made things way too confusing for me, especially when trying to use it in a VirtualMachineArgs. Hence, my plea for a simple example :-)
I think I almost got it by trying to replicate https://github.com/pulumi/pulumi-vsphere/blob/master/examples/webserver/index.ts.
For some odd reason, in C#, it only worked when I use the datacenter Moid instead of its Id. Any idea why?
Can you please have a look at full example at https://github.com/rgl/dotnet-pulumi-rke-vsphere-cloud-provider-example (in particular the Stack.cs file)?