Hey everyone: I have a very basic requirement to s...
# azure
c
Hey everyone: I have a very basic requirement to setup and I am building it with Pulumi on Azure. My question is, with Azure, it seems like the NIC needs to be created before the VM is created, what is the "proper" way to get the NIC to show up as a child of the VM? It seems like a large hassle to create the VM without a nic, create a nic, then update the VM with the NIC and update the opts. If this is the "right" way to do it, then I will keep down that path. I tried asking the Pulumi AI for help, but it didn't seem to quite get at what I was asking.
s
Hi David, I am sure the best thing to do is create the nic before the VM, like Azure do in the portal and most of the bicep scripts
Id = networkInterface.Id
<--- this part here will make it wait for the interface to be created before creating the VM
var networkInterface = new NetworkInterface(resourcePrefix + "daves-nic", new NetworkInterfaceArgs { stuff for nic });
var newVM= new VirtualMachine("vm" + resourcePrefix, new VirtualMachineArgs {
stuff for vm
NetworkProfile = new Pulumi.AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new new Pulumi.AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs {
Id = networkInterface.Id, //associate the network here
Primary = true,
}
},
});
a cloud machine without a NIC is a bit pointless
c
I understand that point. I wasn't sure how others using Pulumi and Azure were seeing the resource dependencies on build. If this is how it is with Azure (not a Pulumi issue) then I can just chalk it up to Microsoft being just bit backwards in their own special way. 🙂
The same can be said about a cloud nic without a vm... one without the other is a bit pointless.
s
well you can attach a nic to other things like gateways and services but you would do the same sort of Association 🙂