public async Task Get() { #region Snippet:Managing_Networks_GetANetworkInterface NetworkInterfaceCollection networkInterfaceCollection = resourceGroup.GetNetworkInterfaces(); NetworkInterface virtualNetwork = await networkInterfaceCollection.GetAsync("myVnet"); Console.WriteLine(virtualNetwork.Data.Name); #endregion }
public async Task DeleteNetworkInterface() { #region Snippet:Managing_Networks_DeleteANetworkInterface NetworkInterfaceCollection networkInterfaceCollection = resourceGroup.GetNetworkInterfaces(); NetworkInterface virtualNetwork = await networkInterfaceCollection.GetAsync("myVnet"); await virtualNetwork.DeleteAsync(); #endregion }
public async Task <NetworkInterface> CreateNetworkInterface(string name, string publicIpAddressId, string subnetId, string location, string ipConfigName, NetworkInterfaceCollection networkInterfaceCollection) { var nicParameters = new NetworkInterfaceData() { Location = location, Tags = { { "key", "value" } }, IpConfigurations = { new NetworkInterfaceIPConfigurationData() { Name = ipConfigName, PrivateIPAllocationMethod = IPAllocationMethod.Dynamic, Subnet = new SubnetData() { Id = subnetId } } } }; if (!string.IsNullOrEmpty(publicIpAddressId)) { nicParameters.IpConfigurations[0].PublicIPAddress = new PublicIPAddressData() /*Id = publicIpAddressId*/ } { ; } // Test NIC apis var operation = InstrumentOperation(await networkInterfaceCollection.CreateOrUpdateAsync(true, name, nicParameters)); await operation.WaitForCompletionAsync(); Response <NetworkInterface> getNicResponse = await networkInterfaceCollection.GetAsync(name); Assert.AreEqual(getNicResponse.Value.Data.Name, name); // because its a single CA nic, primaryOnCA is always true Assert.True(getNicResponse.Value.Data.IpConfigurations[0].Primary); Assert.AreEqual("Succeeded", getNicResponse.Value.Data.ProvisioningState.ToString()); return(getNicResponse); }