diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Helpers/NetworkServiceClientTestBase.cs b/sdk/network/Azure.ResourceManager.Network/tests/Helpers/NetworkServiceClientTestBase.cs index 2807940d470f9..5a9be22a71c24 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Helpers/NetworkServiceClientTestBase.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Helpers/NetworkServiceClientTestBase.cs @@ -40,7 +40,7 @@ public Resources.Subscription Subscription { get { - return ArmClient.GetSubscriptions().Get(TestEnvironment.SubscriptionId).Value; + return ArmClient.DefaultSubscription; } } @@ -116,9 +116,7 @@ private ComputeManagementClient GetComputeManagementClient() protected async Task> CreateResourceGroup(string name) { - string location = TestEnvironment.Location; - await ResourceGroupsOperations.CreateOrUpdateAsync(name, new Resources.Models.ResourceGroup(location)); - return await ArmClient.DefaultSubscription.GetResourceGroups().GetAsync(name); + return await Subscription.GetResourceGroups().CreateOrUpdateAsync(name, new ResourceGroupData(TestEnvironment.Location)); } public async Task CreateVm( @@ -304,6 +302,25 @@ public async Task UpdateDefaultExpressRouteCircuitWithMicro return getCircuitResponse; } + public async Task CreateDefaultPublicIpAddress(string name, string domainNameLabel, string location, PublicIPAddressContainer publicIPAddressContainer) + { + var publicIp = new PublicIPAddressData() + { + Location = location, + Tags = { { "key", "value" } }, + PublicIPAllocationMethod = IPAllocationMethod.Dynamic, + DnsSettings = new PublicIPAddressDnsSettings() { DomainNameLabel = domainNameLabel } + }; + + // Put nic1PublicIpAddress + Operation putPublicIpAddressOperation = await publicIPAddressContainer.StartCreateOrUpdateAsync(name, publicIp); + Response putPublicIpAddressResponse = await putPublicIpAddressOperation.WaitForCompletionAsync(); + Assert.AreEqual("Succeeded", putPublicIpAddressResponse.Value.Data.ProvisioningState.ToString()); + Response getPublicIpAddressResponse = await publicIPAddressContainer.GetAsync(name); + + return getPublicIpAddressResponse; + } + public async Task CreateDefaultPublicIpAddress(string name, string resourceGroupName, string domainNameLabel, string location) { var publicIp = new PublicIPAddressData() @@ -359,7 +376,40 @@ public async Task CreateNetworkInterface(string name, string r return getNicResponse; } + public async Task CreateNetworkInterface(string name, string publicIpAddressId, string subnetId, + string location, string ipConfigName, NetworkInterfaceContainer networkInterfaceContainer) + { + var nicParameters = new NetworkInterfaceData() + { + Location = location, + Tags = { { "key", "value" } }, + IpConfigurations = { + new NetworkInterfaceIPConfiguration() + { + 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 + await networkInterfaceContainer.StartCreateOrUpdateAsync(name, nicParameters); + Response getNicResponse = await networkInterfaceContainer.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; + } public async Task CreateVirtualNetwork(string vnetName, string subnetName, string resourceGroupName, string location) { var vnet = new VirtualNetworkData() @@ -384,6 +434,29 @@ public async Task CreateVirtualNetwork(string vnetName, string s return getVnetResponse; } + public async Task CreateVirtualNetwork(string vnetName, string subnetName, string location, VirtualNetworkContainer virtualNetworkContainer) + { + var vnet = new VirtualNetworkData() + { + Location = location, + + AddressSpace = new AddressSpace() + { + AddressPrefixes = { "10.0.0.0/16", } + }, + DhcpOptions = new DhcpOptions() + { + DnsServers = { "10.1.1.1", "10.1.2.4" } + }, + Subnets = { new SubnetData() { Name = subnetName, AddressPrefix = "10.0.0.0/24", } } + }; + + await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); + Response getVnetResponse = await virtualNetworkContainer.GetAsync(vnetName); + + return getVnetResponse; + } + public static string GetChildLbResourceId(string subscriptionId, string resourceGroupName, string lbname, string childResourceType, string childResourceName) { return @@ -406,6 +479,11 @@ protected LoadBalancerContainer GetLoadBalancerContainer(string resourceGroupNam return GetResourceGroup(resourceGroupName).GetLoadBalancers(); } + protected LoadBalancerContainer GetLoadBalancerContainer(Resources.ResourceGroup resourceGroup) + { + return resourceGroup.GetLoadBalancers(); + } + protected PublicIPAddressContainer GetPublicIPAddressContainer(string resourceGroupName) { return GetResourceGroup(resourceGroupName).GetPublicIPAddresses(); @@ -416,6 +494,10 @@ protected VirtualNetworkContainer GetVirtualNetworkContainer(string resourceGrou return GetResourceGroup(resourceGroupName).GetVirtualNetworks(); } + protected VirtualNetworkContainer GetVirtualNetworkContainer(Resources.ResourceGroup resourceGroup) + { + return resourceGroup.GetVirtualNetworks(); + } protected NetworkInterfaceContainer GetNetworkInterfaceContainer(string resourceGroupName) { return GetResourceGroup(resourceGroupName).GetNetworkInterfaces(); diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/ExpandResourceTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/ExpandResourceTests.cs index 4e3b5458cde3e..ace38cb9ed1b3 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/ExpandResourceTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/ExpandResourceTests.cs @@ -41,7 +41,7 @@ public async Task ExpandResourceTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/loadBalancers"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create lbPublicIP string lbPublicIpName = Recording.GenerateAssetName("azsmnet"); @@ -49,15 +49,14 @@ public async Task ExpandResourceTest() PublicIPAddress lbPublicIp = await CreateDefaultPublicIpAddress( lbPublicIpName, - resourceGroupName, lbDomaingNameLabel, - location); + location, + resourceGroup.Value.GetPublicIPAddresses()); // Create Vnet string vnetName = Recording.GenerateAssetName("azsmnet"); string subnetName = Recording.GenerateAssetName("azsmnet"); - - VirtualNetwork vnet = await CreateVirtualNetwork(vnetName, subnetName, resourceGroupName, location); + VirtualNetwork vnet = await CreateVirtualNetwork(vnetName, subnetName, location, resourceGroup.Value.GetVirtualNetworks()); // Create Nics string nic1name = Recording.GenerateAssetName("azsmnet"); @@ -66,27 +65,27 @@ public async Task ExpandResourceTest() NetworkInterface nic1 = await CreateNetworkInterface( nic1name, - resourceGroupName, null, vnet.Data.Subnets[0].Id, location, - "ipconfig"); + "ipconfig", + resourceGroup.Value.GetNetworkInterfaces()); NetworkInterface nic2 = await CreateNetworkInterface( nic2name, - resourceGroupName, null, vnet.Data.Subnets[0].Id, location, - "ipconfig"); + "ipconfig", + resourceGroup.Value.GetNetworkInterfaces()); NetworkInterface nic3 = await CreateNetworkInterface( nic3name, - resourceGroupName, null, vnet.Data.Subnets[0].Id, location, - "ipconfig"); + "ipconfig", + resourceGroup.Value.GetNetworkInterfaces()); // Create the LoadBalancer var lbName = Recording.GenerateAssetName("azsmnet"); @@ -187,9 +186,10 @@ public async Task ExpandResourceTest() }; // Create the loadBalancer - var loadBalancerContainer = GetResourceGroup(resourceGroupName).GetLoadBalancers(); + var loadBalancerContainer = resourceGroup.Value.GetLoadBalancers(); Operation putLoadBalancerOperation = await loadBalancerContainer.StartCreateOrUpdateAsync(lbName, loadBalancer); - await putLoadBalancerOperation.WaitForCompletionAsync();; + await putLoadBalancerOperation.WaitForCompletionAsync(); + ; Response getLoadBalancer = await loadBalancerContainer.GetAsync(lbName); // Associate the nic with LB @@ -201,15 +201,17 @@ public async Task ExpandResourceTest() //nic3.IpConfigurations.First().LoadBalancerInboundNatRules.Add(getLoadBalancer.Value.InboundNatRules[1]); // Put Nics - var networkInterfaceContainer = GetResourceGroup(resourceGroupName).GetNetworkInterfaces(); + var networkInterfaceContainer = resourceGroup.Value.GetNetworkInterfaces(); NetworkInterfacesCreateOrUpdateOperation createOrUpdateOperation1 = await networkInterfaceContainer.StartCreateOrUpdateAsync(nic1name, nic1.Data); - await createOrUpdateOperation1.WaitForCompletionAsync();; + await createOrUpdateOperation1.WaitForCompletionAsync(); NetworkInterfacesCreateOrUpdateOperation createOrUpdateOperation2 = await networkInterfaceContainer.StartCreateOrUpdateAsync(nic2name, nic2.Data); - await createOrUpdateOperation2.WaitForCompletionAsync();; + await createOrUpdateOperation2.WaitForCompletionAsync(); + ; NetworkInterfacesCreateOrUpdateOperation createOrUpdateOperation3 = await networkInterfaceContainer.StartCreateOrUpdateAsync(nic3name, nic3.Data); - await createOrUpdateOperation3.WaitForCompletionAsync();; + await createOrUpdateOperation3.WaitForCompletionAsync(); + ; // Get Nics await networkInterfaceContainer.GetAsync(nic1name); @@ -265,7 +267,7 @@ public async Task ExpandResourceTest() } // Get subnet with expanded ipconfigurations - Response subnet = await GetResourceGroup(resourceGroupName).GetVirtualNetworks().Get(vnetName).Value.GetSubnets().GetAsync( + Response subnet = await resourceGroup.Value.GetVirtualNetworks().Get(vnetName).Value.GetSubnets().GetAsync( subnetName, "IPConfigurations"); @@ -278,7 +280,7 @@ public async Task ExpandResourceTest() } // Get publicIPAddress with expanded ipconfigurations - Response publicip = await GetResourceGroup(resourceGroupName).GetPublicIPAddresses().GetAsync( + Response publicip = await resourceGroup.Value.GetPublicIPAddresses().GetAsync( lbPublicIpName, "IPConfiguration"); @@ -289,7 +291,8 @@ public async Task ExpandResourceTest() // Delete LoadBalancer Operation deleteOperation = await loadBalancerContainer.Get(lbName).Value.StartDeleteAsync(); - await deleteOperation.WaitForCompletionResponseAsync();; + await deleteOperation.WaitForCompletionResponseAsync(); + ; // Verify Delete AsyncPageable listLoadBalancerAP = loadBalancerContainer.GetAllAsync(); @@ -302,7 +305,7 @@ public async Task ExpandResourceTest() await networkInterfaceContainer.Get(nic3name).Value.StartDeleteAsync(); // Delete all PublicIPAddresses - await GetResourceGroup(resourceGroupName).GetPublicIPAddresses().Get(lbPublicIpName).Value.StartDeleteAsync(); + await resourceGroup.Value.GetPublicIPAddresses().Get(lbPublicIpName).Value.StartDeleteAsync(); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/GatewayOperationsTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/GatewayOperationsTests.cs index 7ddb965f2bfe5..04d9e041a685d 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/GatewayOperationsTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/GatewayOperationsTests.cs @@ -53,7 +53,7 @@ public async Task VirtualNetworkGatewayOperationsApisTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/virtualnetworkgateways"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // 1. CreateVirtualNetworkGateway API // A. Prerequisite:- Create PublicIPAddress(Gateway Ip) using Put PublicIPAddress API @@ -109,7 +109,8 @@ public async Task VirtualNetworkGatewayOperationsApisTest() var virtualNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGateways(); VirtualNetworkGatewaysCreateOrUpdateOperation putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, virtualNetworkGateway); - Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); // 2. GetVirtualNetworkGateway API @@ -130,7 +131,8 @@ public async Task VirtualNetworkGatewayOperationsApisTest() Tier = VirtualNetworkGatewaySkuTier.Standard }; putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, getVirtualNetworkGatewayResponse.Value.Data); - putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); @@ -138,7 +140,8 @@ public async Task VirtualNetworkGatewayOperationsApisTest() // 4A. ResetVirtualNetworkGateway API VirtualNetworkGatewaysResetOperation resetVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.Get(virtualNetworkGatewayName).Value.StartResetAsync(); - await resetVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + await resetVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; // 4B. GetVirtualNetworkgateway API after ResetVirtualNetworkGateway API was called getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); @@ -158,7 +161,8 @@ public async Task VirtualNetworkGatewayOperationsApisTest() // TODO: restore to specific type //VirtualNetworkGatewaysDeleteOperation deleteOperation = await virtualNetworkGatewayContainer.Get(virtualNetworkGatewayName).Value.StartDeleteAsync(); var deleteOperation = await virtualNetworkGatewayContainer.Get(virtualNetworkGatewayName).Value.StartDeleteAsync(); - await deleteOperation.WaitForCompletionResponseAsync();; + await deleteOperation.WaitForCompletionResponseAsync(); + ; // 6B. ListVitualNetworkGateways API after deleting VirtualNetworkGateway listVirtualNetworkGatewayResponseAP = virtualNetworkGatewayContainer.GetAllAsync(); @@ -174,7 +178,7 @@ public async Task LocalNettworkGatewayOperationsApisTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/localNetworkGateways"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // 1. CreateLocalNetworkGateway API string localNetworkGatewayName = Recording.GenerateAssetName("azsmnet"); @@ -193,9 +197,10 @@ public async Task LocalNettworkGatewayOperationsApisTest() } }; - var localNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetLocalNetworkGateways(); + var localNetworkGatewayContainer = resourceGroup.Value.GetLocalNetworkGateways(); LocalNetworkGatewaysCreateOrUpdateOperation putLocalNetworkGatewayResponseOperation = await localNetworkGatewayContainer.StartCreateOrUpdateAsync(localNetworkGatewayName, localNetworkGateway); - Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putLocalNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); // 2. GetLocalNetworkGateway API @@ -211,7 +216,8 @@ public async Task LocalNettworkGatewayOperationsApisTest() getLocalNetworkGatewayResponse.Value.Data.LocalNetworkAddressSpace = new AddressSpace() { AddressPrefixes = { newAddressPrefixes, } }; putLocalNetworkGatewayResponseOperation = await localNetworkGatewayContainer.StartCreateOrUpdateAsync(localNetworkGatewayName, getLocalNetworkGatewayResponse.Value.Data); - putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync();; + putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putLocalNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); // 3B. GetLocalNetworkGateway API after Updating LocalNetworkGateway LocalNetworkAddressSpace from "192.168.0.0/16" => "200.168.0.0/16" @@ -232,7 +238,8 @@ public async Task LocalNettworkGatewayOperationsApisTest() // TODO: restore to specific delete var deleteOperation = await getLocalNetworkGatewayResponse.Value.StartDeleteAsync(); //var deleteOperation = await localNetworkGatewayContainer.Get(localNetworkGatewayName).Value.StartDeleteAsync(); - await deleteOperation.WaitForCompletionResponseAsync();; + await deleteOperation.WaitForCompletionResponseAsync(); + ; // 5B. ListLocalNetworkGateways API after DeleteLocalNetworkGateway API was called listLocalNetworkGatewayResponseAP = localNetworkGatewayContainer.GetAllAsync(); @@ -247,7 +254,7 @@ public async Task VirtualNetworkGatewayConnectionWithBgpTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/connections"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create a local network gateway with BGP string localNetworkGatewayName = Recording.GenerateAssetName("azsmnet"); @@ -270,9 +277,10 @@ public async Task VirtualNetworkGatewayConnectionWithBgpTest() } }; - var localNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetLocalNetworkGateways(); + var localNetworkGatewayContainer = resourceGroup.Value.GetLocalNetworkGateways(); LocalNetworkGatewaysCreateOrUpdateOperation putLocalNetworkGatewayResponseOperation = await localNetworkGatewayContainer.StartCreateOrUpdateAsync(localNetworkGatewayName, localNetworkGateway); - Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putLocalNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); Response getLocalNetworkGatewayResponse = await localNetworkGatewayContainer.GetAsync(localNetworkGatewayName); @@ -281,15 +289,15 @@ public async Task VirtualNetworkGatewayConnectionWithBgpTest() string publicIpName = Recording.GenerateAssetName("azsmnet"); string domainNameLabel = Recording.GenerateAssetName("azsmnet"); - PublicIPAddress nic1publicIp = await CreateDefaultPublicIpAddress(publicIpName, resourceGroupName, domainNameLabel, location); + PublicIPAddress nic1publicIp = await CreateDefaultPublicIpAddress(publicIpName, domainNameLabel, location, resourceGroup.Value.GetPublicIPAddresses()); Console.WriteLine("PublicIPAddress(Gateway Ip) :{0}", nic1publicIp.Id); // b. Create Virtual Network using Put VirtualNetwork API string vnetName = Recording.GenerateAssetName("azsmnet"); string subnetName = "GatewaySubnet"; - await CreateVirtualNetwork(vnetName, subnetName, resourceGroupName, location); - Response getSubnetResponse = await GetResourceGroup(resourceGroupName).GetVirtualNetworks().Get(vnetName).Value.GetSubnets().GetAsync(subnetName); + await CreateVirtualNetwork(vnetName, subnetName, location,resourceGroup.Value.GetVirtualNetworks()); + Response getSubnetResponse = await resourceGroup.Value.GetVirtualNetworks().Get(vnetName).Value.GetSubnets().GetAsync(subnetName); Console.WriteLine("Virtual Network GatewaySubnet Id: {0}", getSubnetResponse.Value.Id); //c. CreateVirtualNetworkGateway API (Also, Set Default local network site) @@ -332,9 +340,10 @@ public async Task VirtualNetworkGatewayConnectionWithBgpTest() } }; - var virtualNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGateways(); + var virtualNetworkGatewayContainer = resourceGroup.Value.GetVirtualNetworkGateways(); VirtualNetworkGatewaysCreateOrUpdateOperation putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, virtualNetworkGateway); - Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); Console.WriteLine("Virtual Network Gateway is deployed successfully."); Response getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); @@ -353,9 +362,10 @@ public async Task VirtualNetworkGatewayConnectionWithBgpTest() EnableBgp = true }; - var virtualNetworkGatewayConnectionContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGatewayConnections(); + var virtualNetworkGatewayConnectionContainer = resourceGroup.Value.GetVirtualNetworkGatewayConnections(); VirtualNetworkGatewayConnectionsCreateOrUpdateOperation putVirtualNetworkGatewayConnectionResponseOperation = await virtualNetworkGatewayConnectionContainer.StartCreateOrUpdateAsync(VirtualNetworkGatewayConnectionName, virtualNetworkGatewayConneciton); - Response putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayConnectionResponse.Value.Data.ProvisioningState.ToString()); Assert.True(putVirtualNetworkGatewayConnectionResponse.Value.Data.EnableBgp, "Enabling BGP for this connection must succeed"); @@ -385,7 +395,8 @@ public async Task VirtualNetworkGatewayConnectionWithBgpTest() // TODO: use specific delete var deleteOperation = await getVirtualNetworkGatewayConnectionResponse.Value.StartDeleteAsync(); //VirtualNetworkGatewayConnectionsDeleteOperation deleteOperation = await virtualNetworkGatewayConnectionContainer.StartDeleteAsync(VirtualNetworkGatewayConnectionName); - await deleteOperation.WaitForCompletionResponseAsync();; + await deleteOperation.WaitForCompletionResponseAsync(); + ; // 5B. ListVitualNetworkGatewayConnections API after DeleteVirtualNetworkGatewayConnection API called listVirtualNetworkGatewayConectionResponseAP = virtualNetworkGatewayConnectionContainer.GetAllAsync(); @@ -401,7 +412,7 @@ public async Task VirtualNetworkGatewayConnectionWithIpsecPoliciesTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/connections"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // 1. CreateVirtualNetworkGatewayConnection API //A. Create LocalNetworkGateway2 @@ -419,9 +430,10 @@ public async Task VirtualNetworkGatewayConnectionWithIpsecPoliciesTest() } }; - var localNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetLocalNetworkGateways(); + var localNetworkGatewayContainer = resourceGroup.Value.GetLocalNetworkGateways(); LocalNetworkGatewaysCreateOrUpdateOperation putLocalNetworkGatewayResponseOperation = await localNetworkGatewayContainer.StartCreateOrUpdateAsync(localNetworkGatewayName, localNetworkGateway); - Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putLocalNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); Response getLocalNetworkGatewayResponse = await localNetworkGatewayContainer.GetAsync(localNetworkGatewayName); @@ -430,15 +442,15 @@ public async Task VirtualNetworkGatewayConnectionWithIpsecPoliciesTest() string publicIpName = Recording.GenerateAssetName("azsmnet"); string domainNameLabel = Recording.GenerateAssetName("azsmnet"); - PublicIPAddress nic1publicIp = await CreateDefaultPublicIpAddress(publicIpName, resourceGroupName, domainNameLabel, location); + PublicIPAddress nic1publicIp = await CreateDefaultPublicIpAddress(publicIpName, domainNameLabel, location, resourceGroup.Value.GetPublicIPAddresses()); Console.WriteLine("PublicIPAddress(Gateway Ip) :{0}", nic1publicIp.Id); // b. Create Virtual Network using Put VirtualNetwork API string vnetName = Recording.GenerateAssetName("azsmnet"); string subnetName = "GatewaySubnet"; - await CreateVirtualNetwork(vnetName, subnetName, resourceGroupName, location); - Response getSubnetResponse = await GetResourceGroup(resourceGroupName).GetVirtualNetworks().Get(vnetName).Value.GetSubnets().GetAsync(subnetName); + await CreateVirtualNetwork(vnetName, subnetName, location, resourceGroup.Value.GetVirtualNetworks()); + Response getSubnetResponse = await resourceGroup.Value.GetVirtualNetworks().Get(vnetName).Value.GetSubnets().GetAsync(subnetName); Console.WriteLine("Virtual Network GatewaySubnet Id: {0}", getSubnetResponse.Value.Id); //c. CreateVirtualNetworkGateway API (Also, Set Default local network site) @@ -475,9 +487,10 @@ public async Task VirtualNetworkGatewayConnectionWithIpsecPoliciesTest() } }; - var virtualNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGateways(); + var virtualNetworkGatewayContainer = resourceGroup.Value.GetVirtualNetworkGateways(); VirtualNetworkGatewaysCreateOrUpdateOperation putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, virtualNetworkGateway); - Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); Console.WriteLine("Virtual Network Gateway is deployed successfully."); Response getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); @@ -498,9 +511,10 @@ public async Task VirtualNetworkGatewayConnectionWithIpsecPoliciesTest() virtualNetworkGatewayConnection.UsePolicyBasedTrafficSelectors = true; - var virtualNetworkGatewayConnectionContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGatewayConnections(); + var virtualNetworkGatewayConnectionContainer = resourceGroup.Value.GetVirtualNetworkGatewayConnections(); VirtualNetworkGatewayConnectionsCreateOrUpdateOperation putVirtualNetworkGatewayConnectionResponseOperation = await virtualNetworkGatewayConnectionContainer.StartCreateOrUpdateAsync(VirtualNetworkGatewayConnectionName, virtualNetworkGatewayConnection); - Response putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayConnectionResponse.Value.Data.ProvisioningState.ToString()); // 2. GetVirtualNetworkGatewayConnection API @@ -531,7 +545,8 @@ public async Task VirtualNetworkGatewayConnectionWithIpsecPoliciesTest() virtualNetworkGatewayConnection.IpsecPolicies.Add(new IpsecPolicy(600, 2048, IpsecEncryption.Gcmaes256, IpsecIntegrity.Gcmaes256, IkeEncryption.AES256, IkeIntegrity.SHA384, DhGroup.DHGroup2048, PfsGroup.ECP384)); putVirtualNetworkGatewayConnectionResponseOperation = await virtualNetworkGatewayConnectionContainer.StartCreateOrUpdateAsync(VirtualNetworkGatewayConnectionName, virtualNetworkGatewayConnection); - putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync();; + putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayConnectionResponse.Value.Data.ProvisioningState.ToString()); // 3B. GetVirtualNetworkGatewayConnection API after Updating @@ -559,7 +574,8 @@ public async Task VirtualNetworkGatewayConnectionWithIpsecPoliciesTest() (virtualNetworkGatewayConnection.IpsecPolicies as ChangeTrackingList).Reset(); putVirtualNetworkGatewayConnectionResponseOperation = await virtualNetworkGatewayConnectionContainer.StartCreateOrUpdateAsync(VirtualNetworkGatewayConnectionName, virtualNetworkGatewayConnection); - putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync();; + putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayConnectionResponse.Value.Data.ProvisioningState.ToString()); // 4B. GetVirtualNetworkGatewayConnection API after Updating @@ -585,7 +601,8 @@ public async Task VirtualNetworkGatewayConnectionWithIpsecPoliciesTest() // TOOD //var deleteOperation = await virtualNetworkGatewayConnectionContainer.StartDeleteAsync(VirtualNetworkGatewayConnectionName); var deleteOperation = await putVirtualNetworkGatewayConnectionResponse.Value.StartDeleteAsync(); - await deleteOperation.WaitForCompletionResponseAsync();; + await deleteOperation.WaitForCompletionResponseAsync(); + ; // 5B. ListVitualNetworkGatewayConnections API after DeleteVirtualNetworkGatewayConnection API called listVirtualNetworkGatewayConectionResponseAP = virtualNetworkGatewayConnectionContainer.GetAllAsync(); @@ -601,7 +618,7 @@ public async Task VirtualNetworkGatewayConnectionOperationsApisTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/connections"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // 1. CreateVirtualNetworkGatewayConnection API //A. Create LocalNetworkGateway2 @@ -619,9 +636,9 @@ public async Task VirtualNetworkGatewayConnectionOperationsApisTest() } }; - var localNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetLocalNetworkGateways(); + var localNetworkGatewayContainer = resourceGroup.Value.GetLocalNetworkGateways(); LocalNetworkGatewaysCreateOrUpdateOperation putLocalNetworkGatewayResponseOperation = await localNetworkGatewayContainer.StartCreateOrUpdateAsync(localNetworkGatewayName, localNetworkGateway); - Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync(); Assert.AreEqual("Succeeded", putLocalNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); Response getLocalNetworkGatewayResponse = await localNetworkGatewayContainer.GetAsync(localNetworkGatewayName); @@ -630,16 +647,16 @@ public async Task VirtualNetworkGatewayConnectionOperationsApisTest() string publicIpName = Recording.GenerateAssetName("azsmnet"); string domainNameLabel = Recording.GenerateAssetName("azsmnet"); - PublicIPAddress nic1publicIp = await CreateDefaultPublicIpAddress(publicIpName, resourceGroupName, domainNameLabel, location); + PublicIPAddress nic1publicIp = await CreateDefaultPublicIpAddress(publicIpName, domainNameLabel, location, resourceGroup.Value.GetPublicIPAddresses()); Console.WriteLine("PublicIPAddress(Gateway Ip) :{0}", nic1publicIp.Id); // b. Create Virtual Network using Put VirtualNetwork API string vnetName = Recording.GenerateAssetName("azsmnet"); string subnetName = "GatewaySubnet"; - await CreateVirtualNetwork(vnetName, subnetName, resourceGroupName, location); + await CreateVirtualNetwork(vnetName, subnetName, location, resourceGroup.Value.GetVirtualNetworks()); - Response getSubnetResponse = await GetResourceGroup(resourceGroupName).GetVirtualNetworks().Get(vnetName).Value.GetSubnets().GetAsync(subnetName); + Response getSubnetResponse = await resourceGroup.Value.GetVirtualNetworks().Get(vnetName).Value.GetSubnets().GetAsync(subnetName); Console.WriteLine("Virtual Network GatewaySubnet Id: {0}", getSubnetResponse.Value.Id); //c. CreateVirtualNetworkGateway API (Also, Set Default local network site) @@ -675,9 +692,10 @@ public async Task VirtualNetworkGatewayConnectionOperationsApisTest() } }; - var virtualNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGateways(); + var virtualNetworkGatewayContainer = resourceGroup.Value.GetVirtualNetworkGateways(); VirtualNetworkGatewaysCreateOrUpdateOperation putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, virtualNetworkGateway); - Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); Console.WriteLine("Virtual Network Gateway is deployed successfully."); Response getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); @@ -695,9 +713,10 @@ public async Task VirtualNetworkGatewayConnectionOperationsApisTest() SharedKey = "abc" }; - var virtualNetworkGatewayConnectionContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGatewayConnections(); + var virtualNetworkGatewayConnectionContainer = resourceGroup.Value.GetVirtualNetworkGatewayConnections(); VirtualNetworkGatewayConnectionsCreateOrUpdateOperation putVirtualNetworkGatewayConnectionResponseOperation = await virtualNetworkGatewayConnectionContainer.StartCreateOrUpdateAsync(VirtualNetworkGatewayConnectionName, virtualNetworkGatewayConneciton); - Response putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayConnectionResponse.Value.Data.ProvisioningState.ToString()); // 2. GetVirtualNetworkGatewayConnection API @@ -719,7 +738,8 @@ public async Task VirtualNetworkGatewayConnectionOperationsApisTest() // 2A. Remove Default local network site getVirtualNetworkGatewayResponse.Value.Data.GatewayDefaultSite = null; putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, getVirtualNetworkGatewayResponse.Value.Data); - putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); Assert.Null(getVirtualNetworkGatewayResponse.Value.Data.GatewayDefaultSite); @@ -731,7 +751,8 @@ public async Task VirtualNetworkGatewayConnectionOperationsApisTest() virtualNetworkGatewayConneciton.RoutingWeight = 4; putVirtualNetworkGatewayConnectionResponseOperation = await virtualNetworkGatewayConnectionContainer.StartCreateOrUpdateAsync(VirtualNetworkGatewayConnectionName, virtualNetworkGatewayConneciton); - putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync();; + putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayConnectionResponse.Value.Data.ProvisioningState.ToString()); // 3B. GetVirtualNetworkGatewayConnection API after Updating RoutingWeight = 3 => 4, SharedKey = "abc"=> "xyz" @@ -782,7 +803,7 @@ public async Task VirtualNetworkGatewayConnectionSharedKeyOperationsApisTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/connections"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // 1. SetVirtualNetworkGatewayConnectionSharedKey API // Pre-requsite:- CreateVirtualNetworkGatewayConnection first @@ -834,7 +855,8 @@ public async Task VirtualNetworkGatewayConnectionSharedKeyOperationsApisTest() var virtualNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGateways(); VirtualNetworkGatewaysCreateOrUpdateOperation putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, virtualNetworkGateway); - Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); Response getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); @@ -854,7 +876,8 @@ public async Task VirtualNetworkGatewayConnectionSharedKeyOperationsApisTest() var localNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetLocalNetworkGateways(); LocalNetworkGatewaysCreateOrUpdateOperation putLocalNetworkGatewayResponseOperation = await localNetworkGatewayContainer.StartCreateOrUpdateAsync(localNetworkGatewayName, localNetworkGateway); - Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putLocalNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); Response getLocalNetworkGatewayResponse = await localNetworkGatewayContainer.GetAsync(localNetworkGatewayName); getLocalNetworkGatewayResponse.Value.Data.Location = location; @@ -871,7 +894,8 @@ public async Task VirtualNetworkGatewayConnectionSharedKeyOperationsApisTest() var virtualNetworkGatewayConnectionContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGatewayConnections(); VirtualNetworkGatewayConnectionsCreateOrUpdateOperation putVirtualNetworkGatewayConnectionResponseOperation = await virtualNetworkGatewayConnectionContainer.StartCreateOrUpdateAsync(VirtualNetworkGatewayConnectionName, virtualNetworkGatewayConneciton); - Response putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayConnectionResponse.Value.Data.ProvisioningState.ToString()); Response getVirtualNetworkGatewayConnectionResponse = await virtualNetworkGatewayConnectionContainer.GetAsync(VirtualNetworkGatewayConnectionName); @@ -882,7 +906,8 @@ public async Task VirtualNetworkGatewayConnectionSharedKeyOperationsApisTest() string connectionSharedKeyName = VirtualNetworkGatewayConnectionName; ConnectionResetSharedKey connectionResetSharedKey = new ConnectionResetSharedKey(50); VirtualNetworkGatewayConnectionsResetSharedKeyOperation resetConnectionResetSharedKeyResponseOperation = await getVirtualNetworkGatewayConnectionResponse.Value.StartResetSharedKeyAsync(connectionResetSharedKey.KeyLength); - await resetConnectionResetSharedKeyResponseOperation.WaitForCompletionAsync();; + await resetConnectionResetSharedKeyResponseOperation.WaitForCompletionAsync(); + ; // 2B. GetVirtualNetworkGatewayConnectionSharedKey API after VirtualNetworkGatewayConnectionResetSharedKey API was called Response getconnectionSharedKeyResponse = await getVirtualNetworkGatewayConnectionResponse.Value.GetSharedKeyAsync(); @@ -909,7 +934,7 @@ public async Task VirtualNetworkGatewayP2SOperationsApisTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/virtualnetworkgateways"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create LocalNetworkGateway to set as default site string localNetworkGatewayName = Recording.GenerateAssetName("azsmnet"); @@ -925,7 +950,8 @@ public async Task VirtualNetworkGatewayP2SOperationsApisTest() var localNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetLocalNetworkGateways(); LocalNetworkGatewaysCreateOrUpdateOperation putLocalNetworkGatewayResponseOperation = await localNetworkGatewayContainer.StartCreateOrUpdateAsync(localNetworkGatewayName, localNetworkGateway); - Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putLocalNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); Response getLocalNetworkGatewayResponse = await localNetworkGatewayContainer.GetAsync(localNetworkGatewayName); @@ -983,7 +1009,8 @@ public async Task VirtualNetworkGatewayP2SOperationsApisTest() var virtualNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGateways(); VirtualNetworkGatewaysCreateOrUpdateOperation putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, virtualNetworkGateway); - Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); // 2.GetVirtualNetworkGateway API @@ -1008,7 +1035,8 @@ public async Task VirtualNetworkGatewayP2SOperationsApisTest() }; getVirtualNetworkGatewayResponse.Value.Data.VpnClientConfiguration.VpnClientAddressPool.AddressPrefixes.Add(newAddressPrefixes); putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, getVirtualNetworkGatewayResponse.Value.Data); - putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); @@ -1028,7 +1056,8 @@ public async Task VirtualNetworkGatewayP2SOperationsApisTest() getVirtualNetworkGatewayResponse.Value.Data.VpnClientConfiguration.VpnClientRootCertificates.Add(clientRootCert); putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, getVirtualNetworkGatewayResponse.Value.Data); - putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); // 4. Get client Root certificates @@ -1043,7 +1072,8 @@ public async Task VirtualNetworkGatewayP2SOperationsApisTest() ProcessorArchitecture = ProcessorArchitecture.Amd64 }; VirtualNetworkGatewaysGeneratevpnclientpackageOperation packageUrlOperation = await virtualNetworkGatewayContainer.Get(virtualNetworkGatewayName).Value.StartGeneratevpnclientpackageAsync(vpnClientParameters); - await packageUrlOperation.WaitForCompletionAsync();; + await packageUrlOperation.WaitForCompletionAsync(); + ; //Assert.NotNull(packageUrl); //Assert.NotEmpty(packageUrl); //Console.WriteLine("Vpn client package Url = {0}", packageUrl); @@ -1051,7 +1081,8 @@ public async Task VirtualNetworkGatewayP2SOperationsApisTest() // 6.Delete client Root certificate getVirtualNetworkGatewayResponse.Value.Data.VpnClientConfiguration.VpnClientRootCertificates.Clear(); putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, getVirtualNetworkGatewayResponse.Value.Data); - putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); @@ -1071,7 +1102,8 @@ public async Task VirtualNetworkGatewayP2SOperationsApisTest() getVirtualNetworkGatewayResponse.Value.Data.VpnClientConfiguration.VpnClientRevokedCertificates.Add(sampleClientCert); putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, getVirtualNetworkGatewayResponse.Value.Data); - putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); Assert.True(getVirtualNetworkGatewayResponse.Value.Data.VpnClientConfiguration.VpnClientRevokedCertificates.Count() == 1); @@ -1080,7 +1112,8 @@ public async Task VirtualNetworkGatewayP2SOperationsApisTest() // 9. Unrevoke previously revoked Vpn client certificate getVirtualNetworkGatewayResponse.Value.Data.VpnClientConfiguration.VpnClientRevokedCertificates.Clear(); putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, getVirtualNetworkGatewayResponse.Value.Data); - putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); Assert.True(getVirtualNetworkGatewayResponse.Value.Data.VpnClientConfiguration.VpnClientRevokedCertificates.Count() == 0); @@ -1094,7 +1127,7 @@ public async Task VirtualNetworkGatewayActiveActiveFeatureTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/virtualnetworkgateways"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // 1. Create Active-Active VirtualNetworkGateway // A. Prerequisite:- Create PublicIPAddress(Gateway Ip) using Put PublicIPAddress API @@ -1155,7 +1188,8 @@ public async Task VirtualNetworkGatewayActiveActiveFeatureTest() var virtualNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGateways(); VirtualNetworkGatewaysCreateOrUpdateOperation putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, virtualNetworkGateway); - Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); // 2. GetVirtualNetworkGateway API @@ -1176,7 +1210,8 @@ public async Task VirtualNetworkGatewayActiveActiveFeatureTest() getVirtualNetworkGatewayResponse.Value.Data.Active = false; getVirtualNetworkGatewayResponse.Value.Data.IpConfigurations.Remove(getVirtualNetworkGatewayResponse.Value.Data.IpConfigurations.First(config => config.Name.Equals(ipconfig2.Name))); putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, getVirtualNetworkGatewayResponse.Value.Data); - putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); @@ -1187,7 +1222,8 @@ public async Task VirtualNetworkGatewayActiveActiveFeatureTest() getVirtualNetworkGatewayResponse.Value.Data.Active = true; getVirtualNetworkGatewayResponse.Value.Data.IpConfigurations.Add(ipconfig2); putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, getVirtualNetworkGatewayResponse.Value.Data); - putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); @@ -1202,7 +1238,7 @@ public async Task VirtualNetworkGatewayBgpRouteApiTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/virtualnetworkgateways"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string gatewaySubnetName = "GatewaySubnet"; string gw1Name = Recording.GenerateAssetName("azsmnet"); @@ -1227,7 +1263,8 @@ public async Task VirtualNetworkGatewayBgpRouteApiTest() PublicIPAddress publicIPAddress = await CreateDefaultPublicIpAddress(gw1IpName, resourceGroupName, gw1IpDomainNameLabel, location); var virtualNetworkContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation virtualNetworksCreateOrUpdateOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnet1Name, vnet1); - Response vnet1Response = await virtualNetworksCreateOrUpdateOperation.WaitForCompletionAsync();; + Response vnet1Response = await virtualNetworksCreateOrUpdateOperation.WaitForCompletionAsync(); + ; Response gw1Subnet = await virtualNetworkContainer.Get(vnet1Name).Value.GetSubnets().GetAsync(gatewaySubnetName); VirtualNetworkGatewayIPConfiguration ipconfig1 = new VirtualNetworkGatewayIPConfiguration() { @@ -1254,7 +1291,8 @@ public async Task VirtualNetworkGatewayBgpRouteApiTest() Subnets = { new SubnetData() { Name = gatewaySubnetName, AddressPrefix = "10.2.1.0/24", } } }; VirtualNetworksCreateOrUpdateOperation vnet2Operation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnet2Name, vnet2); - VirtualNetwork vnet2Response = await vnet2Operation.WaitForCompletionAsync();; + VirtualNetwork vnet2Response = await vnet2Operation.WaitForCompletionAsync(); + ; Response gw2Subnet = await virtualNetworkContainer.Get(vnet2Name).Value.GetSubnets().GetAsync(gatewaySubnetName); VirtualNetworkGatewayIPConfiguration ipconfig2 = new VirtualNetworkGatewayIPConfiguration() { @@ -1337,13 +1375,16 @@ await Task.Factory.StartNew(async() => // get bgp info from gw1 VirtualNetworkGatewaysGetLearnedRoutesOperation learnedRoutesOperation = await virtualNetworkGatewayContainer.Get(gw1Name).Value.StartGetLearnedRoutesAsync(); - Response learnedRoutes = await learnedRoutesOperation.WaitForCompletionAsync();; + Response learnedRoutes = await learnedRoutesOperation.WaitForCompletionAsync(); + ; Assert.True(learnedRoutes.Value.Value.Count() > 0, "At least one route should be learned from gw2"); VirtualNetworkGatewaysGetAdvertisedRoutesOperation advertisedRoutesOperation = await virtualNetworkGatewayContainer.Get(gw1Name).Value.StartGetAdvertisedRoutesAsync(gw2IpResponse.Value.Data.IpAddress); - Response advertisedRoutes = await advertisedRoutesOperation.WaitForCompletionAsync();; + Response advertisedRoutes = await advertisedRoutesOperation.WaitForCompletionAsync(); + ; Assert.True(learnedRoutes.Value.Value.Count() > 0, "At least one route should be advertised to gw2"); VirtualNetworkGatewaysGetBgpPeerStatusOperation gw1PeersOperation = await virtualNetworkGatewayContainer.Get(gw1Name).Value.StartGetBgpPeerStatusAsync(); - Response gw1Peers = await gw1PeersOperation.WaitForCompletionAsync();; + Response gw1Peers = await gw1PeersOperation.WaitForCompletionAsync(); + ; Assert.True(gw1Peers.Value.Value.Count() > 0, "At least one peer should be connected"); } @@ -1354,7 +1395,7 @@ public async Task VirtualNetworkGatewayGenerateVpnProfileTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/virtualnetworkgateways"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // 1.CreateVirtualNetworkGateway // A.Prerequisite:-Create PublicIPAddress(Gateway Ip) using Put PublicIPAddress API @@ -1414,7 +1455,8 @@ public async Task VirtualNetworkGatewayGenerateVpnProfileTest() var virtualNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGateways(); VirtualNetworkGatewaysCreateOrUpdateOperation putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, virtualNetworkGateway); - Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); // 2.GetVirtualNetworkGateway API @@ -1451,7 +1493,8 @@ public async Task VirtualNetworkGatewayGenerateVpnProfileTest() getVirtualNetworkGatewayResponse.Value.Data.VpnClientConfiguration.VpnClientAddressPool.AddressPrefixes.Add(newAddressPrefixes); putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, getVirtualNetworkGatewayResponse.Value.Data); - putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); // 5.Generate P2S Vpnclient package @@ -1483,7 +1526,7 @@ public async Task VirtualNetworkGatewayVpnDeviceConfigurationApisTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/connections"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // CreateVirtualNetworkGatewayConnection API // Create LocalNetworkGateway2 @@ -1503,7 +1546,8 @@ public async Task VirtualNetworkGatewayVpnDeviceConfigurationApisTest() var localNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetLocalNetworkGateways(); LocalNetworkGatewaysCreateOrUpdateOperation putLocalNetworkGatewayResponseOperation = await localNetworkGatewayContainer.StartCreateOrUpdateAsync(localNetworkGatewayName, localNetworkGateway); - Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putLocalNetworkGatewayResponse = await putLocalNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putLocalNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); Response getLocalNetworkGatewayResponse = await localNetworkGatewayContainer.GetAsync(localNetworkGatewayName); @@ -1554,7 +1598,8 @@ public async Task VirtualNetworkGatewayVpnDeviceConfigurationApisTest() var virtualNetworkGatewayContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGateways(); VirtualNetworkGatewaysCreateOrUpdateOperation putVirtualNetworkGatewayResponseOperation = await virtualNetworkGatewayContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayName, virtualNetworkGateway); - Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayResponse = await putVirtualNetworkGatewayResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayResponse.Value.Data.ProvisioningState.ToString()); Console.WriteLine("Virtual Network Gateway is deployed successfully."); Response getVirtualNetworkGatewayResponse = await virtualNetworkGatewayContainer.GetAsync(virtualNetworkGatewayName); @@ -1570,7 +1615,7 @@ public async Task VirtualNetworkGatewayVpnDeviceConfigurationApisTest() }; virtualNetworkGatewayConnection.IpsecPolicies.Add( - new IpsecPolicy(300,1024,IpsecEncryption.AES128,IpsecIntegrity.SHA256,IkeEncryption.AES192,IkeIntegrity.SHA1,DhGroup.DHGroup2, PfsGroup.PFS1) + new IpsecPolicy(300, 1024, IpsecEncryption.AES128, IpsecIntegrity.SHA256, IkeEncryption.AES192, IkeIntegrity.SHA1, DhGroup.DHGroup2, PfsGroup.PFS1) ); virtualNetworkGatewayConnection.UsePolicyBasedTrafficSelectors = true; @@ -1578,7 +1623,8 @@ public async Task VirtualNetworkGatewayVpnDeviceConfigurationApisTest() var virtualNetworkGatewayConnectionContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworkGatewayConnections(); VirtualNetworkGatewayConnectionsCreateOrUpdateOperation putVirtualNetworkGatewayConnectionResponseOperation = await virtualNetworkGatewayConnectionContainer.StartCreateOrUpdateAsync(virtualNetworkGatewayConnectionName, virtualNetworkGatewayConnection); - Response putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync();; + Response putVirtualNetworkGatewayConnectionResponse = await putVirtualNetworkGatewayConnectionResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putVirtualNetworkGatewayConnectionResponse.Value.Data.ProvisioningState.ToString()); // 2. GetVirtualNetworkGatewayConnection API diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/LoadBalancerTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/LoadBalancerTests.cs index 59a3faf55e0f3..91c9365388efc 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/LoadBalancerTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/LoadBalancerTests.cs @@ -41,7 +41,7 @@ public async Task LoadBalancerApiTestAsync() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/loadBalancers"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create lbPublicIP string lbPublicIpName = Recording.GenerateAssetName("azsmnet"); @@ -49,9 +49,9 @@ public async Task LoadBalancerApiTestAsync() PublicIPAddress lbPublicIp = await CreateDefaultPublicIpAddress( lbPublicIpName, - resourceGroupName, lbDomaingNameLabel, - location); + location, + resourceGroup.Value.GetPublicIPAddresses()); // Create the LoadBalancer string lbName = Recording.GenerateAssetName("azsmnet"); @@ -153,9 +153,10 @@ public async Task LoadBalancerApiTestAsync() }; // Create the loadBalancer - LoadBalancersCreateOrUpdateOperation putLoadBalancerOperation = await GetResourceGroup(resourceGroupName).GetLoadBalancers().StartCreateOrUpdateAsync(lbName, loadBalancer); - await putLoadBalancerOperation.WaitForCompletionAsync();; - Response getLoadBalancer = await GetResourceGroup(resourceGroupName).GetLoadBalancers().GetAsync(lbName); + LoadBalancersCreateOrUpdateOperation putLoadBalancerOperation = await resourceGroup.Value.GetLoadBalancers().StartCreateOrUpdateAsync(lbName, loadBalancer); + await putLoadBalancerOperation.WaitForCompletionAsync(); + ; + Response getLoadBalancer = await resourceGroup.Value.GetLoadBalancers().GetAsync(lbName); // Verify the GET LoadBalancer Assert.AreEqual(lbName, getLoadBalancer.Value.Data.Name); @@ -185,7 +186,7 @@ public async Task LoadBalancerApiTestAsync() Assert.NotNull(getLoadBalancer.Value.Data.ResourceGuid); // Verify List LoadBalancer - AsyncPageable listLoadBalancerAP = GetResourceGroup(resourceGroupName).GetLoadBalancers().GetAllAsync(); + AsyncPageable listLoadBalancerAP = resourceGroup.Value.GetLoadBalancers().GetAllAsync(); List listLoadBalancer = await listLoadBalancerAP.ToEnumerableAsync(); Has.One.EqualTo(listLoadBalancer); Assert.AreEqual(lbName, listLoadBalancer.First().Data.Name); @@ -200,7 +201,7 @@ public async Task LoadBalancerApiTestAsync() Assert.NotNull(listLoadBalancerSubscription.First().Data.Etag); // Verify List BackendAddressPools in LoadBalancer - var backendAddressPoolContainer = GetResourceGroup(resourceGroupName).GetLoadBalancers().Get(lbName).Value.GetBackendAddressPools(); + var backendAddressPoolContainer = resourceGroup.Value.GetLoadBalancers().Get(lbName).Value.GetBackendAddressPools(); AsyncPageable listLoadBalancerBackendAddressPoolsAP = backendAddressPoolContainer.GetAllAsync(); List listLoadBalancerBackendAddressPools = await listLoadBalancerBackendAddressPoolsAP.ToEnumerableAsync(); Has.One.EqualTo(listLoadBalancerBackendAddressPools); @@ -213,7 +214,7 @@ public async Task LoadBalancerApiTestAsync() Assert.NotNull(getLoadBalancerBackendAddressPool.Value.Data.Etag); // Verify List FrontendIPConfigurations in LoadBalancer - var loadBalancerContainer = GetResourceGroup(resourceGroupName).GetLoadBalancers(); + var loadBalancerContainer = resourceGroup.Value.GetLoadBalancers(); var loadBalancerOperations = loadBalancerContainer.Get(lbName).Value; AsyncPageable listLoadBalancerFrontendIPConfigurationsAP = loadBalancerOperations.GetLoadBalancerFrontendIPConfigurationsAsync(); List listLoadBalancerFrontendIPConfigurations = await listLoadBalancerFrontendIPConfigurationsAP.ToEnumerableAsync(); @@ -270,7 +271,8 @@ public async Task LoadBalancerApiTestAsync() // Verify Put InboundNatRule in LoadBalancer var inboundNatRuleContainer = loadBalancerOperations.GetInboundNatRules(); InboundNatRulesCreateOrUpdateOperation putInboundNatRuleOperation = await inboundNatRuleContainer.StartCreateOrUpdateAsync(inboundNatRule3Name, inboundNatRule3Params); - Response putInboundNatRule = await putInboundNatRuleOperation.WaitForCompletionAsync();; + Response putInboundNatRule = await putInboundNatRuleOperation.WaitForCompletionAsync(); + ; Assert.AreEqual(inboundNatRule3Name, putInboundNatRule.Value.Data.Name); Assert.AreEqual(TransportProtocol.Tcp, putInboundNatRule.Value.Data.Protocol); Assert.AreEqual(3391, putInboundNatRule.Value.Data.FrontendPort); @@ -302,7 +304,8 @@ public async Task LoadBalancerApiTestAsync() // Delete LoadBalancer LoadBalancersDeleteOperation deleteOperation1 = await loadBalancerOperations.StartDeleteAsync(); - await deleteOperation1.WaitForCompletionResponseAsync();; + await deleteOperation1.WaitForCompletionResponseAsync(); + ; // Verify Delete listLoadBalancerAP = loadBalancerContainer.GetAllAsync(); @@ -319,13 +322,13 @@ public async Task LoadBalancerApiTestWithDynamicIp() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/loadBalancers"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create Vnet string vnetName = Recording.GenerateAssetName("azsmnet"); string subnetName = Recording.GenerateAssetName("azsmnet"); - VirtualNetwork vnet = await CreateVirtualNetwork(vnetName, subnetName, resourceGroupName, location); + VirtualNetwork vnet = await CreateVirtualNetwork(vnetName, subnetName, location, resourceGroup.Value.GetVirtualNetworks()); // Create the LoadBalancer string lbName = Recording.GenerateAssetName("azsmnet"); @@ -424,10 +427,11 @@ public async Task LoadBalancerApiTestWithDynamicIp() }; // Create the loadBalancer - var loadBalancerContainer = GetLoadBalancerContainer(resourceGroupName); + var loadBalancerContainer = GetLoadBalancerContainer(resourceGroup); LoadBalancersCreateOrUpdateOperation putLoadBalancerOperation = await loadBalancerContainer.StartCreateOrUpdateAsync(lbName, loadbalancerparamater); - await putLoadBalancerOperation.WaitForCompletionAsync();; - Response getLoadBalancer = await GetResourceGroup(resourceGroupName).GetLoadBalancers().GetAsync(lbName); + await putLoadBalancerOperation.WaitForCompletionAsync(); + ; + Response getLoadBalancer = await resourceGroup.Value.GetLoadBalancers().GetAsync(lbName); // Verify the GET LoadBalancer Assert.AreEqual(lbName, getLoadBalancer.Value.Data.Name); @@ -471,7 +475,8 @@ public async Task LoadBalancerApiTestWithDynamicIp() // TODO ADO 5998 //LoadBalancersDeleteOperation deleteOperation = await ArmClient.GetGenericResourcesOperations(getLoadBalancer.Value.Id).StartDelete(); var deleteOperation = await ArmClient.GetGenericResourceOperations(getLoadBalancer.Value.Id).StartDeleteAsync(); - await deleteOperation.WaitForCompletionResponseAsync();; + await deleteOperation.WaitForCompletionResponseAsync(); + ; // Verify Delete listLoadBalancerAP = loadBalancerContainer.GetAllAsync(); @@ -488,13 +493,13 @@ public async Task LoadBalancerApiTestWithStaticIp() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/loadBalancers"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create Vnet string vnetName = Recording.GenerateAssetName("azsmnet"); string subnetName = Recording.GenerateAssetName("azsmnet"); - VirtualNetwork vnet = await CreateVirtualNetwork(vnetName, subnetName, resourceGroupName, location); + VirtualNetwork vnet = await CreateVirtualNetwork(vnetName, subnetName, location, resourceGroup.Value.GetVirtualNetworks()); // Create the LoadBalancer string lbName = Recording.GenerateAssetName("azsmnet"); @@ -591,9 +596,10 @@ public async Task LoadBalancerApiTestWithStaticIp() }; // Create the loadBalancer - var loadBalancerContainer = GetLoadBalancerContainer(resourceGroupName); + var loadBalancerContainer = GetLoadBalancerContainer(resourceGroup); LoadBalancersCreateOrUpdateOperation putLoadBalancerOperation = await loadBalancerContainer.StartCreateOrUpdateAsync(lbName, loadbalancerparamater); - await putLoadBalancerOperation.WaitForCompletionAsync();; + await putLoadBalancerOperation.WaitForCompletionAsync(); + ; Response getLoadBalancer = await loadBalancerContainer.GetAsync(lbName); // Verify the GET LoadBalancer @@ -640,7 +646,8 @@ public async Task LoadBalancerApiTestWithStaticIp() // Delete LoadBalancer LoadBalancersDeleteOperation deleteOperation = await getLoadBalancer.Value.StartDeleteAsync(); - await deleteOperation.WaitForCompletionResponseAsync();; + await deleteOperation.WaitForCompletionResponseAsync(); + ; // Verify Delete listLoadBalancerAP = loadBalancerContainer.GetAllAsync(); @@ -657,13 +664,13 @@ public async Task LoadBalancerApiTestWithDistributionPolicy() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/loadBalancers"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create Vnet string vnetName = Recording.GenerateAssetName("azsmnet"); string subnetName = Recording.GenerateAssetName("azsmnet"); - VirtualNetwork vnet = await CreateVirtualNetwork(vnetName, subnetName, resourceGroupName, location); + VirtualNetwork vnet = await CreateVirtualNetwork(vnetName, subnetName, location, resourceGroup.Value.GetVirtualNetworks()); // Create the LoadBalancer string lbName = Recording.GenerateAssetName("azsmnet"); @@ -760,7 +767,7 @@ public async Task LoadBalancerApiTestWithDistributionPolicy() }; // Create the loadBalancer - var loadBalancerContainer = GetResourceGroup(resourceGroupName).GetLoadBalancers(); + var loadBalancerContainer = resourceGroup.Value.GetLoadBalancers(); await loadBalancerContainer.StartCreateOrUpdateAsync(lbName, loadbalancerparamater); Response getLoadBalancer = await loadBalancerContainer.GetAsync(lbName); @@ -830,7 +837,7 @@ public async Task CreateEmptyLoadBalancer() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/loadBalancers"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create the empty LoadBalancer string lbname = Recording.GenerateAssetName("azsmnet"); @@ -839,9 +846,10 @@ public async Task CreateEmptyLoadBalancer() var loadbalancerparamater = new LoadBalancerData() { Location = location, }; // Create the loadBalancer - var loadBalancerContainer = GetResourceGroup(resourceGroupName).GetLoadBalancers(); + var loadBalancerContainer = resourceGroup.Value.GetLoadBalancers(); LoadBalancersCreateOrUpdateOperation putLoadBalancerOperation = await loadBalancerContainer.StartCreateOrUpdateAsync(lbname, loadbalancerparamater); - await putLoadBalancerOperation.WaitForCompletionAsync();; + await putLoadBalancerOperation.WaitForCompletionAsync(); + ; Response getLoadBalancer = await loadBalancerContainer.GetAsync(lbname); // Verify the GET LoadBalancer @@ -854,7 +862,8 @@ public async Task CreateEmptyLoadBalancer() Assert.False(getLoadBalancer.Value.Data.InboundNatRules.Any()); // Delete LoadBalancer - await (await getLoadBalancer.Value.StartDeleteAsync()).WaitForCompletionResponseAsync();; + await (await getLoadBalancer.Value.StartDeleteAsync()).WaitForCompletionResponseAsync(); + ; // Verify Delete AsyncPageable listLoadBalancerAP = loadBalancerContainer.GetAllAsync(); @@ -868,13 +877,13 @@ public async Task UpdateLoadBalancerRule() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/loadBalancers"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create Vnet string vnetName = Recording.GenerateAssetName("azsmnet"); string subnetName = Recording.GenerateAssetName("azsmnet"); - VirtualNetwork vnet = await CreateVirtualNetwork(vnetName, subnetName, resourceGroupName, location); + VirtualNetwork vnet = await CreateVirtualNetwork(vnetName, subnetName, location, resourceGroup.Value.GetVirtualNetworks()); // Create the LoadBalancer with an lb rule and no probe string lbname = Recording.GenerateAssetName("azsmnet"); @@ -925,7 +934,7 @@ public async Task UpdateLoadBalancerRule() }; // Create the loadBalancer - var loadBalancerContainer = GetResourceGroup(resourceGroupName).GetLoadBalancers(); + var loadBalancerContainer = resourceGroup.Value.GetLoadBalancers(); await loadBalancerContainer.StartCreateOrUpdateAsync(lbname, loadbalancerparamater); Response getLoadBalancer = await loadBalancerContainer.GetAsync(lbname); @@ -958,7 +967,8 @@ public async Task UpdateLoadBalancerRule() // update load balancer LoadBalancersCreateOrUpdateOperation putLoadBalancerOperation = await loadBalancerContainer.StartCreateOrUpdateAsync(lbname, getLoadBalancer.Value.Data); - await putLoadBalancerOperation.WaitForCompletionAsync();; + await putLoadBalancerOperation.WaitForCompletionAsync(); + ; getLoadBalancer = await loadBalancerContainer.GetAsync(lbname); // Verify the GET LoadBalancer @@ -972,7 +982,8 @@ public async Task UpdateLoadBalancerRule() Assert.False(getLoadBalancer.Value.Data.InboundNatRules.Any()); // Delete LoadBalancer - await (await getLoadBalancer.Value.StartDeleteAsync()).WaitForCompletionResponseAsync();; + await (await getLoadBalancer.Value.StartDeleteAsync()).WaitForCompletionResponseAsync(); + ; // Verify Delete AsyncPageable listLoadBalancerAP = loadBalancerContainer.GetAllAsync(); @@ -989,28 +1000,28 @@ public async Task LoadBalancerApiNicAssociationTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/loadBalancers"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create lbPublicIP string lbPublicIpName = Recording.GenerateAssetName("azsmnet"); string lbDomaingNameLabel = Recording.GenerateAssetName("azsmnet"); - PublicIPAddress lbPublicIp = await CreateDefaultPublicIpAddress(lbPublicIpName, resourceGroupName, lbDomaingNameLabel, location); + PublicIPAddress lbPublicIp = await CreateDefaultPublicIpAddress(lbPublicIpName, lbDomaingNameLabel, location, resourceGroup.Value.GetPublicIPAddresses()); // Create Vnet string vnetName = Recording.GenerateAssetName("azsmnet"); string subnetName = Recording.GenerateAssetName("azsmnet"); - VirtualNetwork vnet = await CreateVirtualNetwork(vnetName, subnetName, resourceGroupName, location); + VirtualNetwork vnet = await CreateVirtualNetwork(vnetName, subnetName, location, resourceGroup.Value.GetVirtualNetworks()); // Create Nics string nic1name = Recording.GenerateAssetName("azsmnet"); string nic2name = Recording.GenerateAssetName("azsmnet"); string nic3name = Recording.GenerateAssetName("azsmnet"); - NetworkInterface nic1 = await CreateNetworkInterface(nic1name, resourceGroupName, null, vnet.Data.Subnets[0].Id, location, "ipconfig"); - NetworkInterface nic2 = await CreateNetworkInterface(nic2name, resourceGroupName, null, vnet.Data.Subnets[0].Id, location, "ipconfig"); - NetworkInterface nic3 = await CreateNetworkInterface(nic3name, resourceGroupName, null, vnet.Data.Subnets[0].Id, location, "ipconfig"); + NetworkInterface nic1 = await CreateNetworkInterface(nic1name, null, vnet.Data.Subnets[0].Id, location, "ipconfig", resourceGroup.Value.GetNetworkInterfaces()); + NetworkInterface nic2 = await CreateNetworkInterface(nic2name, null, vnet.Data.Subnets[0].Id, location, "ipconfig", resourceGroup.Value.GetNetworkInterfaces()); + NetworkInterface nic3 = await CreateNetworkInterface(nic3name, null, vnet.Data.Subnets[0].Id, location, "ipconfig", resourceGroup.Value.GetNetworkInterfaces()); // Create the LoadBalancer string lbName = Recording.GenerateAssetName("azsmnet"); @@ -1111,9 +1122,10 @@ public async Task LoadBalancerApiNicAssociationTest() }; // Create the loadBalancer - var loadBalancerContainer = GetResourceGroup(resourceGroupName).GetLoadBalancers(); + var loadBalancerContainer = resourceGroup.Value.GetLoadBalancers(); LoadBalancersCreateOrUpdateOperation putLoadBalancerOperation = await loadBalancerContainer.StartCreateOrUpdateAsync(lbName, loadBalancer); - await putLoadBalancerOperation.WaitForCompletionAsync();; + await putLoadBalancerOperation.WaitForCompletionAsync(); + ; Response getLoadBalancer = await loadBalancerContainer.GetAsync(lbName); // Associate the nic with LB @@ -1125,15 +1137,18 @@ public async Task LoadBalancerApiNicAssociationTest() ipConfigurationsList.First().LoadBalancerInboundNatRules.Add(getLoadBalancer.Value.Data.InboundNatRules[1]); // Put Nics - var networkInterfaceContainer = GetResourceGroup(resourceGroupName).GetNetworkInterfaces(); + var networkInterfaceContainer = resourceGroup.Value.GetNetworkInterfaces(); NetworkInterfacesCreateOrUpdateOperation nic1Operation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nic1name, nic1.Data); - await nic1Operation.WaitForCompletionAsync();; + await nic1Operation.WaitForCompletionAsync(); + ; NetworkInterfacesCreateOrUpdateOperation nic2Operation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nic2name, nic2.Data); - await nic2Operation.WaitForCompletionAsync();; + await nic2Operation.WaitForCompletionAsync(); + ; NetworkInterfacesCreateOrUpdateOperation nic3Operation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nic3name, nic3.Data); - await nic3Operation.WaitForCompletionAsync();; + await nic3Operation.WaitForCompletionAsync(); + ; // Get Nics nic1 = await networkInterfaceContainer.GetAsync(nic1name); @@ -1155,7 +1170,8 @@ public async Task LoadBalancerApiNicAssociationTest() // Delete LoadBalancer LoadBalancersDeleteOperation deleteOperation = await getLoadBalancer.Value.StartDeleteAsync(); - await deleteOperation.WaitForCompletionResponseAsync();; + await deleteOperation.WaitForCompletionResponseAsync(); + ; // Verify Delete AsyncPageable listLoadBalancerAP = loadBalancerContainer.GetAllAsync(); @@ -1177,13 +1193,13 @@ public async Task LoadBalancerNatPoolTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/loadBalancers"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create lbPublicIP string lbPublicIpName = Recording.GenerateAssetName("azsmnet"); string lbDomaingNameLabel = Recording.GenerateAssetName("azsmnet"); - PublicIPAddress lbPublicIp = await CreateDefaultPublicIpAddress(lbPublicIpName, resourceGroupName, lbDomaingNameLabel, location); + PublicIPAddress lbPublicIp = await CreateDefaultPublicIpAddress(lbPublicIpName, lbDomaingNameLabel, location, resourceGroup.Value.GetPublicIPAddresses()); // Create the LoadBalancer string lbName = Recording.GenerateAssetName("azsmnet"); @@ -1222,7 +1238,7 @@ public async Task LoadBalancerNatPoolTest() }; // Create the loadBalancer - var loadBalancerContainer = GetResourceGroup(resourceGroupName).GetLoadBalancers(); + var loadBalancerContainer = resourceGroup.Value.GetLoadBalancers(); await loadBalancerContainer.StartCreateOrUpdateAsync(lbName, loadBalancer); Response getLoadBalancer = await loadBalancerContainer.GetAsync(lbName); @@ -1260,7 +1276,8 @@ public async Task LoadBalancerNatPoolTest() // Delete LoadBalancer LoadBalancersDeleteOperation deleteOperation = await getLoadBalancer.Value.StartDeleteAsync(); - await deleteOperation.WaitForCompletionResponseAsync();; + await deleteOperation.WaitForCompletionResponseAsync(); + ; // Verify Delete AsyncPageable listLoadBalancerAP = loadBalancerContainer.GetAllAsync(); diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/NetworkInterfaceTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/NetworkInterfaceTests.cs index 6c9c19e57e376..c3c454c95bc34 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/NetworkInterfaceTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/NetworkInterfaceTests.cs @@ -41,7 +41,7 @@ public async Task NetworkInterfaceApiTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkInterfaces"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create publicIP string publicIpName = Recording.GenerateAssetName("azsmnet"); @@ -62,9 +62,10 @@ public async Task NetworkInterfaceApiTest() }; // Put PublicIPAddress - var publicIPAddressContainer = GetPublicIPAddressContainer(resourceGroupName); + var publicIPAddressContainer = resourceGroup.Value.GetPublicIPAddresses(); PublicIPAddressesCreateOrUpdateOperation putPublicIpAddressResponseOperation = await publicIPAddressContainer.StartCreateOrUpdateAsync(publicIpName, publicIp); - Response putPublicIpAddressResponse = await putPublicIpAddressResponseOperation.WaitForCompletionAsync();; + Response putPublicIpAddressResponse = await putPublicIpAddressResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putPublicIpAddressResponse.Value.Data.ProvisioningState.ToString()); Response getPublicIpAddressResponse = await publicIPAddressContainer.GetAsync(publicIpName); @@ -89,9 +90,10 @@ public async Task NetworkInterfaceApiTest() Subnets = { new SubnetData() { Name = subnetName, AddressPrefix = "10.0.0.0/24" } } }; - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); - var vnetResponse = await putVnetResponseOperation.WaitForCompletionAsync();; + var vnetResponse = await putVnetResponseOperation.WaitForCompletionAsync(); + ; Response getSubnetResponse = await vnetResponse.Value.GetSubnets().GetAsync(subnetName); // Create Nic @@ -120,9 +122,10 @@ public async Task NetworkInterfaceApiTest() }; // Test NIC apis - var networkInterfaceContainer = GetNetworkInterfaceContainer(resourceGroupName); + var networkInterfaceContainer = resourceGroup.Value.GetNetworkInterfaces(); NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nicName, nicParameters); - await putNicResponseOperation.WaitForCompletionAsync();; + await putNicResponseOperation.WaitForCompletionAsync(); + ; Response getNicResponse = await networkInterfaceContainer.GetAsync(nicName); Assert.AreEqual(getNicResponse.Value.Data.Name, nicName); Assert.AreEqual("Succeeded", getNicResponse.Value.Data.ProvisioningState.ToString()); @@ -138,7 +141,7 @@ public async Task NetworkInterfaceApiTest() Assert.NotNull(getNicResponse.Value.Data.ResourceGuid); // Verify List IpConfigurations in NetworkInterface - var networkInterfaceOperations = GetNetworkInterfaceContainer(resourceGroupName).Get(nicName).Value; + var networkInterfaceOperations = resourceGroup.Value.GetNetworkInterfaces().Get(nicName).Value; AsyncPageable listNicIpConfigurationsAP = networkInterfaceOperations.GetNetworkInterfaceIPConfigurationsAsync(); List listNicIpConfigurations = await listNicIpConfigurationsAP.ToEnumerableAsync(); Assert.AreEqual(ipConfigName, listNicIpConfigurations.First().Name); @@ -187,7 +190,7 @@ public async Task NetworkInterfaceWithAcceleratedNetworkingTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkInterfaces"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create Vnet // Populate parameter for Put Vnet @@ -215,9 +218,10 @@ public async Task NetworkInterfaceWithAcceleratedNetworkingTest() } }; - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); - await putVnetResponseOperation.WaitForCompletionAsync();; + await putVnetResponseOperation.WaitForCompletionAsync(); + ; Response getSubnetResponse = await putVnetResponseOperation.Value.GetSubnets().GetAsync(subnetName); // Create Nic @@ -246,9 +250,10 @@ public async Task NetworkInterfaceWithAcceleratedNetworkingTest() }; // Test NIC apis - var networkInterfaceContainer = GetNetworkInterfaceContainer(resourceGroupName); + var networkInterfaceContainer = resourceGroup.Value.GetNetworkInterfaces(); NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nicName, nicParameters); - await putNicResponseOperation.WaitForCompletionAsync();; + await putNicResponseOperation.WaitForCompletionAsync(); + ; Response getNicResponse = await networkInterfaceContainer.GetAsync(nicName); Assert.AreEqual(getNicResponse.Value.Data.Name, nicName); Assert.AreEqual("Succeeded", getNicResponse.Value.Data.ProvisioningState.ToString()); @@ -273,7 +278,7 @@ public async Task NetworkInterfaceMultiIpConfigTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkInterfaces"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create publicIP string publicIpName = Recording.GenerateAssetName("azsmnet"); @@ -291,9 +296,10 @@ public async Task NetworkInterfaceMultiIpConfigTest() }; // Put PublicIPAddress - var publicIPAddressContainer = GetPublicIPAddressContainer(resourceGroupName); + var publicIPAddressContainer = resourceGroup.Value.GetPublicIPAddresses(); PublicIPAddressesCreateOrUpdateOperation putPublicIpAddressResponseOperation = await publicIPAddressContainer.StartCreateOrUpdateAsync(publicIpName, publicIp); - Response putPublicIpAddressResponse = await putPublicIpAddressResponseOperation.WaitForCompletionAsync();; + Response putPublicIpAddressResponse = await putPublicIpAddressResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putPublicIpAddressResponse.Value.Data.ProvisioningState.ToString()); Response getPublicIpAddressResponse = await publicIPAddressContainer.GetAsync(publicIpName); @@ -317,9 +323,10 @@ public async Task NetworkInterfaceMultiIpConfigTest() Subnets = { new SubnetData() { Name = subnetName, AddressPrefix = "10.0.0.0/24" } } }; - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); - await putVnetResponseOperation.WaitForCompletionAsync();; + await putVnetResponseOperation.WaitForCompletionAsync(); + ; Response getSubnetResponse = await putVnetResponseOperation.Value.GetSubnets().GetAsync(subnetName); // Create Nic @@ -360,9 +367,10 @@ public async Task NetworkInterfaceMultiIpConfigTest() }; // Test NIC apis - var networkInterfaceContainer = GetNetworkInterfaceContainer(resourceGroupName); + var networkInterfaceContainer = resourceGroup.Value.GetNetworkInterfaces(); NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nicName, nicParameters); - await putNicResponseOperation.WaitForCompletionAsync();; + await putNicResponseOperation.WaitForCompletionAsync(); + ; Response getNicResponse = await networkInterfaceContainer.GetAsync(nicName); Assert.AreEqual(getNicResponse.Value.Data.Name, nicName); Assert.AreEqual("Succeeded", getNicResponse.Value.Data.ProvisioningState.ToString()); @@ -411,7 +419,7 @@ public async Task AssertMultiIpConfigOnDifferentSubnetFails() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkInterfaces"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create Vnet // Populate parameter for Put Vnet @@ -433,9 +441,10 @@ public async Task AssertMultiIpConfigOnDifferentSubnetFails() } }; - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); - await putVnetResponseOperation.WaitForCompletionAsync();; + await putVnetResponseOperation.WaitForCompletionAsync(); + ; Response getSubnet1Response = await putVnetResponseOperation.Value.GetSubnets().GetAsync(subnetName); Response getSubnet2Response = await putVnetResponseOperation.Value.GetSubnets().GetAsync(subnetName2); @@ -475,8 +484,9 @@ public async Task AssertMultiIpConfigOnDifferentSubnetFails() try { // Test NIC apis - NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await GetNetworkInterfaceContainer(resourceGroupName).StartCreateOrUpdateAsync(nicName, nicParameters); - Response putNicResponse = await putNicResponseOperation.WaitForCompletionAsync();; + NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await resourceGroup.Value.GetNetworkInterfaces().StartCreateOrUpdateAsync(nicName, nicParameters); + Response putNicResponse = await putNicResponseOperation.WaitForCompletionAsync(); + ; } catch (Exception ex) { @@ -490,7 +500,7 @@ public async Task NetworkInterfaceDnsSettingsTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkInterfaces"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create Vnet // Populate parameter for Put Vnet @@ -505,9 +515,10 @@ public async Task NetworkInterfaceDnsSettingsTest() Subnets = { new SubnetData() { Name = subnetName, AddressPrefix = "10.0.0.0/24", } } }; - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); - await putVnetResponseOperation.WaitForCompletionAsync();; + await putVnetResponseOperation.WaitForCompletionAsync(); + ; Response getSubnetResponse = await putVnetResponseOperation.Value.GetSubnets().GetAsync(subnetName); // Create Nic @@ -537,9 +548,10 @@ public async Task NetworkInterfaceDnsSettingsTest() }; // Test NIC apis - var networkInterfaceContainer = GetNetworkInterfaceContainer(resourceGroupName); + var networkInterfaceContainer = resourceGroup.Value.GetNetworkInterfaces(); NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nicName, nicParameters); - await putNicResponseOperation.WaitForCompletionAsync();; + await putNicResponseOperation.WaitForCompletionAsync(); + ; Response getNicResponse = await networkInterfaceContainer.GetAsync(nicName); Assert.AreEqual(getNicResponse.Value.Data.Name, nicName); Assert.AreEqual("Succeeded", getNicResponse.Value.Data.ProvisioningState.ToString()); @@ -574,7 +586,7 @@ public async Task NetworkInterfaceApiIPv6MultiCATest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkInterfaces", Network.Tests.Helpers.FeaturesInfo.Type.All); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create publicIP string publicIpName = Recording.GenerateAssetName("azsmnet"); @@ -592,9 +604,10 @@ public async Task NetworkInterfaceApiIPv6MultiCATest() }; // Put PublicIPAddress - var publicIPAddressContainer = GetPublicIPAddressContainer(resourceGroupName); + var publicIPAddressContainer = resourceGroup.Value.GetPublicIPAddresses(); PublicIPAddressesCreateOrUpdateOperation putPublicIpAddressResponseOperation = await publicIPAddressContainer.StartCreateOrUpdateAsync(publicIpName, publicIp); - Response putPublicIpAddressResponse = await putPublicIpAddressResponseOperation.WaitForCompletionAsync();; + Response putPublicIpAddressResponse = await putPublicIpAddressResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putPublicIpAddressResponse.Value.Data.ProvisioningState.ToString()); await publicIPAddressContainer.GetAsync(publicIpName); @@ -619,9 +632,10 @@ public async Task NetworkInterfaceApiIPv6MultiCATest() Subnets = { new SubnetData() { Name = subnetName, AddressPrefix = "10.0.0.0/24" } } }; - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); - await putVnetResponseOperation.WaitForCompletionAsync();; + await putVnetResponseOperation.WaitForCompletionAsync(); + ; Response getSubnetResponse = await putVnetResponseOperation.Value.GetSubnets().GetAsync(subnetName); // Create Nic @@ -667,9 +681,10 @@ public async Task NetworkInterfaceApiIPv6MultiCATest() }; // Test NIC apis - var networkInterfaceContainer = GetNetworkInterfaceContainer(resourceGroupName); + var networkInterfaceContainer = resourceGroup.Value.GetNetworkInterfaces(); NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nicName, nicParameters); - await putNicResponseOperation.WaitForCompletionAsync();; + await putNicResponseOperation.WaitForCompletionAsync(); + ; Response getNicResponse = await networkInterfaceContainer.GetAsync(nicName); Assert.AreEqual(getNicResponse.Value.Data.Name, nicName); Assert.AreEqual("Succeeded", getNicResponse.Value.Data.ProvisioningState.ToString()); @@ -702,7 +717,8 @@ public async Task NetworkInterfaceApiIPv6MultiCATest() // Delete Nic NetworkInterfacesDeleteOperation deleteOperation = await getNicResponse.Value.StartDeleteAsync(); - await deleteOperation.WaitForCompletionResponseAsync();; + await deleteOperation.WaitForCompletionResponseAsync(); + ; getListNicResponseAP = networkInterfaceContainer.GetAllAsync(); getListNicResponse = await getListNicResponseAP.ToEnumerableAsync(); Assert.IsEmpty(getListNicResponse); @@ -720,7 +736,7 @@ public async Task NetworkInterfaceDnsSettingsTestIdnsSuffix() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkInterfaces"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create Vnet // Populate parameter for Put Vnet @@ -735,9 +751,10 @@ public async Task NetworkInterfaceDnsSettingsTestIdnsSuffix() Subnets = { new SubnetData() { Name = subnetName, AddressPrefix = "10.0.0.0/24" } } }; - var virtualNetworkContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworks(); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); - await putVnetResponseOperation.WaitForCompletionAsync();; + await putVnetResponseOperation.WaitForCompletionAsync(); + ; Response getSubnetResponse = await putVnetResponseOperation.Value.GetSubnets().GetAsync(subnetName); // Create Nic @@ -768,9 +785,10 @@ public async Task NetworkInterfaceDnsSettingsTestIdnsSuffix() }; // Test NIC apis - var networkInterfaceContainer = GetResourceGroup(resourceGroupName).GetNetworkInterfaces(); + var networkInterfaceContainer = resourceGroup.Value.GetNetworkInterfaces(); NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nicName, nicParameters); - await putNicResponseOperation.WaitForCompletionAsync();; + await putNicResponseOperation.WaitForCompletionAsync(); + ; Response getNicResponse = await networkInterfaceContainer.GetAsync(nicName); Assert.AreEqual(getNicResponse.Value.Data.Name, nicName); Assert.AreEqual("Succeeded", getNicResponse.Value.Data.ProvisioningState.ToString()); @@ -805,7 +823,7 @@ public async Task NetworkInterfaceEnableIPForwardingTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkInterfaces"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create Vnet // Populate parameter for Put Vnet @@ -820,9 +838,10 @@ public async Task NetworkInterfaceEnableIPForwardingTest() Subnets = { new SubnetData() { Name = subnetName, AddressPrefix = "10.0.0.0/24", } } }; - var virtualNetworkContainer = GetResourceGroup(resourceGroupName).GetVirtualNetworks(); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); - await putVnetResponseOperation.WaitForCompletionAsync();; + await putVnetResponseOperation.WaitForCompletionAsync(); + ; Response getSubnetResponse = await putVnetResponseOperation.Value.GetSubnets().GetAsync(subnetName); // Create Nic @@ -848,9 +867,10 @@ public async Task NetworkInterfaceEnableIPForwardingTest() }; // Test NIC apis - var networkInterfaceContainer = GetResourceGroup(resourceGroupName).GetNetworkInterfaces(); + var networkInterfaceContainer = resourceGroup.Value.GetNetworkInterfaces(); NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nicName, nicParameters); - await putNicResponseOperation.WaitForCompletionAsync();; + await putNicResponseOperation.WaitForCompletionAsync(); + ; Response getNicResponse = await networkInterfaceContainer.GetAsync(nicName); Assert.AreEqual(getNicResponse.Value.Data.Name, nicName); Assert.AreEqual("Succeeded", getNicResponse.Value.Data.ProvisioningState.ToString()); @@ -883,7 +903,7 @@ public async Task NetworkInterfaceNetworkSecurityGroupTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkInterfaces"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create Vnet // Populate parameter for Put Vnet @@ -900,9 +920,10 @@ public async Task NetworkInterfaceNetworkSecurityGroupTest() Subnets = { new SubnetData() { Name = subnetName, AddressPrefix = "10.0.0.0/24", } } }; - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); - Response putVnetResponse = await putVnetResponseOperation.WaitForCompletionAsync();; + Response putVnetResponse = await putVnetResponseOperation.WaitForCompletionAsync(); + ; // Create network security group string destinationPortRange = "123-3500"; var networkSecurityGroup = new NetworkSecurityGroupData() @@ -926,9 +947,10 @@ public async Task NetworkInterfaceNetworkSecurityGroupTest() }; // Put Nsg - var networkSecurityGroupContainer = GetNetworkSecurityGroupContainer(resourceGroupName); + var networkSecurityGroupContainer = resourceGroup.Value.GetNetworkSecurityGroups(); NetworkSecurityGroupsCreateOrUpdateOperation putNsgResponseOperation = await networkSecurityGroupContainer.StartCreateOrUpdateAsync(networkSecurityGroupName, networkSecurityGroup); - Response putNsgResponse = await putNsgResponseOperation.WaitForCompletionAsync();; + Response putNsgResponse = await putNsgResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putNsgResponse.Value.Data.ProvisioningState.ToString()); // Create Nic @@ -954,9 +976,10 @@ public async Task NetworkInterfaceNetworkSecurityGroupTest() }; // Test NIC apis - var networkInterfaceContainer = GetNetworkInterfaceContainer(resourceGroupName); + var networkInterfaceContainer = resourceGroup.Value.GetNetworkInterfaces(); NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nicName, nicParameters); - await putNicResponseOperation.WaitForCompletionAsync();; + await putNicResponseOperation.WaitForCompletionAsync(); + ; Response getNicResponse = await networkInterfaceContainer.GetAsync(nicName); Assert.AreEqual("Succeeded", getNicResponse.Value.Data.ProvisioningState.ToString()); @@ -987,7 +1010,7 @@ public async Task NetworkInterfaceEffectiveNetworkSecurityGroupTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkInterfaces"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create Vnet // Populate parameter for Put Vnet @@ -1004,9 +1027,10 @@ public async Task NetworkInterfaceEffectiveNetworkSecurityGroupTest() Subnets = { new SubnetData() { Name = subnetName, AddressPrefix = "10.0.0.0/24", } } }; - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); - Response putVnetResponse = await putVnetResponseOperation.WaitForCompletionAsync();; + Response putVnetResponse = await putVnetResponseOperation.WaitForCompletionAsync(); + ; // Create network security group string destinationPortRange = "123-3500"; var networkSecurityGroup = new NetworkSecurityGroupData() @@ -1030,9 +1054,10 @@ public async Task NetworkInterfaceEffectiveNetworkSecurityGroupTest() }; // Put Nsg - var networkSecurityGroupContainer = GetNetworkSecurityGroupContainer(resourceGroupName); + var networkSecurityGroupContainer = resourceGroup.Value.GetNetworkSecurityGroups(); NetworkSecurityGroupsCreateOrUpdateOperation putNsgResponseOperation = await networkSecurityGroupContainer.StartCreateOrUpdateAsync(networkSecurityGroupName, networkSecurityGroup); - Response putNsgResponse = await putNsgResponseOperation.WaitForCompletionAsync();; + Response putNsgResponse = await putNsgResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putNsgResponse.Value.Data.ProvisioningState.ToString()); // Create Nic @@ -1058,9 +1083,10 @@ public async Task NetworkInterfaceEffectiveNetworkSecurityGroupTest() }; // Test NIC apis - var networkInterfaceContainer = GetNetworkInterfaceContainer(resourceGroupName); + var networkInterfaceContainer = resourceGroup.Value.GetNetworkInterfaces(); NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nicName, nicParameters); - await putNicResponseOperation.WaitForCompletionAsync();; + await putNicResponseOperation.WaitForCompletionAsync(); + ; Response getNicResponse = await networkInterfaceContainer.GetAsync(nicName); Assert.AreEqual("Succeeded", getNicResponse.Value.Data.ProvisioningState.ToString()); @@ -1072,7 +1098,8 @@ public async Task NetworkInterfaceEffectiveNetworkSecurityGroupTest() // Get effective NSGs NetworkInterfacesGetEffectiveNetworkSecurityGroupsOperation effectiveNsgsOperation = await getNicResponse.Value.StartGetEffectiveNetworkSecurityGroupsAsync(); - Response effectiveNsgs = await effectiveNsgsOperation.WaitForCompletionAsync();; + Response effectiveNsgs = await effectiveNsgsOperation.WaitForCompletionAsync(); + ; Assert.NotNull(effectiveNsgs); // Delete Nic @@ -1096,7 +1123,7 @@ public async Task NetworkInterfaceEffectiveRouteTableTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkInterfaces"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create Vnet // Populate parameter for Put Vnet @@ -1118,9 +1145,10 @@ public async Task NetworkInterfaceEffectiveRouteTableTest() routeTable.Routes.Add(route1); // Put RouteTable - var routeTableContainer = GetRouteTableContainer(resourceGroupName); + var routeTableContainer = resourceGroup.Value.GetRouteTables(); RouteTablesCreateOrUpdateOperation putRouteTableResponseOperation = await routeTableContainer.StartCreateOrUpdateAsync(routeTableName, routeTable); - Response putRouteTableResponse = await putRouteTableResponseOperation.WaitForCompletionAsync();; + Response putRouteTableResponse = await putRouteTableResponseOperation.WaitForCompletionAsync(); + ; Assert.AreEqual("Succeeded", putRouteTableResponse.Value.Data.ProvisioningState.ToString()); var vnet = new VirtualNetworkData() @@ -1131,9 +1159,10 @@ public async Task NetworkInterfaceEffectiveRouteTableTest() Subnets = { new SubnetData() { Name = subnetName, AddressPrefix = "10.0.0.0/24", RouteTable = putRouteTableResponse.Value.Data } } }; - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); - Response putVnetResponse = await putVnetResponseOperation.WaitForCompletionAsync();; + Response putVnetResponse = await putVnetResponseOperation.WaitForCompletionAsync(); + ; // Create Nic string nicName = Recording.GenerateAssetName("azsmnet"); string ipConfigName = Recording.GenerateAssetName("azsmnet"); @@ -1156,15 +1185,17 @@ public async Task NetworkInterfaceEffectiveRouteTableTest() }; // Test NIC apis - var networkInterfaceContainer = GetNetworkInterfaceContainer(resourceGroupName); + var networkInterfaceContainer = resourceGroup.Value.GetNetworkInterfaces(); NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nicName, nicParameters); - await putNicResponseOperation.WaitForCompletionAsync();; + await putNicResponseOperation.WaitForCompletionAsync(); + ; Response getNicResponse = await networkInterfaceContainer.GetAsync(nicName); Assert.AreEqual("Succeeded", getNicResponse.Value.Data.ProvisioningState.ToString()); // Get effective NSGs NetworkInterfacesGetEffectiveRouteTableOperation effectiveRouteTableOperation = await getNicResponse.Value.StartGetEffectiveRouteTableAsync(); - Response effectiveRouteTable = await effectiveRouteTableOperation.WaitForCompletionAsync();; + Response effectiveRouteTable = await effectiveRouteTableOperation.WaitForCompletionAsync(); + ; Assert.NotNull(effectiveRouteTable); // Delete Nic diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/NetworkSecurityGroupTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/NetworkSecurityGroupTests.cs index f1cb48915e734..a43938e27608e 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/NetworkSecurityGroupTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/NetworkSecurityGroupTests.cs @@ -40,12 +40,13 @@ public async Task NetworkSecurityGroupApiTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkSecurityGroups"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); + string networkSecurityGroupName = Recording.GenerateAssetName("azsmnet"); var networkSecurityGroup = new NetworkSecurityGroupData() { Location = location, }; // Put Nsg - var networkSecurityGroupContainer = GetNetworkSecurityGroupContainer(resourceGroupName); + var networkSecurityGroupContainer = resourceGroup.Value.GetNetworkSecurityGroups(); NetworkSecurityGroupsCreateOrUpdateOperation putNsgResponseOperation = await networkSecurityGroupContainer.StartCreateOrUpdateAsync(networkSecurityGroupName, networkSecurityGroup); Response putNsgResponse = await putNsgResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putNsgResponse.Value.Data.ProvisioningState.ToString()); @@ -107,7 +108,8 @@ public async Task NetworkSecurityGroupWithRulesApiTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkSecurityGroups"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); + string networkSecurityGroupName = Recording.GenerateAssetName("azsmnet"); string securityRule1 = Recording.GenerateAssetName("azsmnet"); string securityRule2 = Recording.GenerateAssetName("azsmnet"); @@ -135,7 +137,7 @@ public async Task NetworkSecurityGroupWithRulesApiTest() }; // Put Nsg - var networkSecurityGroupContainer = GetNetworkSecurityGroupContainer(resourceGroupName); + var networkSecurityGroupContainer = resourceGroup.Value.GetNetworkSecurityGroups(); NetworkSecurityGroupsCreateOrUpdateOperation putNsgResponseOperation = await networkSecurityGroupContainer.StartCreateOrUpdateAsync(networkSecurityGroupName, networkSecurityGroup); Response putNsgResponse = await putNsgResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putNsgResponse.Value.Data.ProvisioningState.ToString()); diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/NetworkWatcherTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/NetworkWatcherTests.cs index 292cd93d86ec1..f659ce32c7d0b 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/NetworkWatcherTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/NetworkWatcherTests.cs @@ -51,11 +51,11 @@ public async Task NetworkWatcherApiTest() string resourceGroupName = Recording.GenerateAssetName("nw"); string location = TestEnvironment.Location; - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string networkWatcherName = Recording.GenerateAssetName("azsmnet"); //Create Network Watcher in the resource group - var networkWatcherContainer = GetNetworkWatcherContainer(resourceGroupName); + var networkWatcherContainer = resourceGroup.Value.GetNetworkWatchers(); var properties = new NetworkWatcherData { Location = location }; var createResponse = await networkWatcherContainer.CreateOrUpdateAsync(networkWatcherName, properties); Assert.AreEqual(networkWatcherName, createResponse.Value.Data.Name); diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/PublicIpAddressTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/PublicIpAddressTests.cs index a55a9f0751eef..1c32c92719d35 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/PublicIpAddressTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/PublicIpAddressTests.cs @@ -40,7 +40,7 @@ public async Task PublicIpAddressApiTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/publicIPAddresses"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create the parameter for PUT PublicIPAddress string publicIpName = Recording.GenerateAssetName("ipname"); @@ -58,7 +58,7 @@ public async Task PublicIpAddressApiTest() }; // Put PublicIPAddress - var publicIPAddressContainer = GetPublicIPAddressContainer(resourceGroupName); + var publicIPAddressContainer = resourceGroup.Value.GetPublicIPAddresses(); PublicIPAddressesCreateOrUpdateOperation putPublicIpAddressResponseOperation = await publicIPAddressContainer.StartCreateOrUpdateAsync(publicIpName, publicIp); Response putPublicIpAddressResponse = await putPublicIpAddressResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putPublicIpAddressResponse.Value.Data.ProvisioningState.ToString()); @@ -95,7 +95,7 @@ public async Task PublicIpAddressApiTestWithIdletTimeoutAndReverseFqdn() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await ResourcesManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/publicIPAddresses"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create the parameter for PUT PublicIPAddress string publicIpName = Recording.GenerateAssetName("ipname"); @@ -112,7 +112,7 @@ public async Task PublicIpAddressApiTestWithIdletTimeoutAndReverseFqdn() }; // Put PublicIPAddress - var publicIPAddressContainer = GetPublicIPAddressContainer(resourceGroupName); + var publicIPAddressContainer = resourceGroup.Value.GetPublicIPAddresses(); PublicIPAddressesCreateOrUpdateOperation putPublicIpAddressResponseOperation = await publicIPAddressContainer.StartCreateOrUpdateAsync(publicIpName, publicIp); Response putPublicIpAddressResponse = await putPublicIpAddressResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putPublicIpAddressResponse.Value.Data.ProvisioningState.ToString()); @@ -160,7 +160,7 @@ public async Task PublicIpAddressApiTestIPv6() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await ResourcesManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/publicIPAddresses"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); // Create the parameter for PUT PublicIPAddress string ipv6PublicIpName = Recording.GenerateAssetName("csmipv6publicip"); @@ -179,7 +179,7 @@ public async Task PublicIpAddressApiTestIPv6() }; // Put PublicIPAddress - var publicIPAddressContainer = GetPublicIPAddressContainer(resourceGroupName); + var publicIPAddressContainer = resourceGroup.Value.GetPublicIPAddresses(); PublicIPAddressesCreateOrUpdateOperation putPublicIpAddressResponseOperation = await publicIPAddressContainer.StartCreateOrUpdateAsync(ipv6PublicIpName, ipv6PublicIp); Response putPublicIpAddressResponse = await putPublicIpAddressResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putPublicIpAddressResponse.Value.Data.ProvisioningState.ToString()); diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/RouteFilterTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/RouteFilterTests.cs index 6e6c1cf9111f6..a9000c594d89e 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/RouteFilterTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/RouteFilterTests.cs @@ -44,9 +44,9 @@ public async Task RouteFilterApiTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/routefilters"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); - var filterContainer = GetRouteFilterContainer(resourceGroupName); + var filterContainer = resourceGroup.Value.GetRouteFilters(); // Create route filter string filterName = "filter"; string ruleName = "rule"; diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/RouteTableTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/RouteTableTests.cs index aa5680261cffb..1e1d972357522 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/RouteTableTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/RouteTableTests.cs @@ -39,12 +39,12 @@ public async Task EmptyRouteTableTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/routeTables"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string routeTableName = Recording.GenerateAssetName("azsmnet"); var routeTable = new RouteTableData() { Location = location, }; // Put RouteTable - var routeTableContainer = GetRouteTableContainer(resourceGroupName); + var routeTableContainer = resourceGroup.Value.GetRouteTables(); RouteTablesCreateOrUpdateOperation putRouteTableResponseOperation = await routeTableContainer.StartCreateOrUpdateAsync(routeTableName, routeTable); Response putRouteTableResponse = await putRouteTableResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putRouteTableResponse.Value.Data.ProvisioningState.ToString()); @@ -78,7 +78,7 @@ public async Task RouteTableApiTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/routeTables"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string routeTableName = Recording.GenerateAssetName("azsmnet"); string route1Name = Recording.GenerateAssetName("azsmnet"); string route2Name = Recording.GenerateAssetName("azsmnet"); @@ -97,7 +97,7 @@ public async Task RouteTableApiTest() routeTable.Routes.Add(route1); // Put RouteTable - var routeTableContainer = GetRouteTableContainer(resourceGroupName); + var routeTableContainer = resourceGroup.Value.GetRouteTables(); RouteTablesCreateOrUpdateOperation putRouteTableResponseOperation = await routeTableContainer.StartCreateOrUpdateAsync(routeTableName, routeTable); Response putRouteTableResponse = await putRouteTableResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putRouteTableResponse.Value.Data.ProvisioningState.ToString()); @@ -159,7 +159,7 @@ public async Task SubnetRouteTableTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/routeTables"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string routeTableName = Recording.GenerateAssetName("azsmnet"); string route1Name = Recording.GenerateAssetName("azsmnet"); @@ -176,7 +176,7 @@ public async Task SubnetRouteTableTest() routeTable.Routes.Add(route1); // Put RouteTable - var routeTableContainer = GetRouteTableContainer(resourceGroupName); + var routeTableContainer = resourceGroup.Value.GetRouteTables(); RouteTablesCreateOrUpdateOperation putRouteTableResponseOperation = await routeTableContainer.StartCreateOrUpdateAsync(routeTableName, routeTable); Response putRouteTableResponse = await putRouteTableResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putRouteTableResponse.Value.Data.ProvisioningState.ToString()); @@ -216,7 +216,7 @@ public async Task SubnetRouteTableTest() } }; - VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await GetVirtualNetworkContainer(resourceGroupName).StartCreateOrUpdateAsync(vnetName, vnet); + VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await resourceGroup.Value.GetVirtualNetworks().StartCreateOrUpdateAsync(vnetName, vnet); Response putVnetResponse = await putVnetResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putVnetResponse.Value.Data.ProvisioningState.ToString()); diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/RouteTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/RouteTests.cs index d5205f6ed182f..7eccd2a2b1050 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/RouteTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/RouteTests.cs @@ -39,7 +39,7 @@ public async Task RoutesApiTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/routeTables"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string routeTableName = Recording.GenerateAssetName("azsmnet"); string route1Name = Recording.GenerateAssetName("azsmnet"); string route2Name = Recording.GenerateAssetName("azsmnet"); @@ -57,7 +57,7 @@ public async Task RoutesApiTest() routeTable.Routes.Add(route1); // Put RouteTable - var routeTableContainer = GetRouteTableContainer(resourceGroupName); + var routeTableContainer = resourceGroup.Value.GetRouteTables(); RouteTablesCreateOrUpdateOperation putRouteTableResponseOperation = await routeTableContainer.StartCreateOrUpdateAsync(routeTableName, routeTable); Response putRouteTableResponse = await putRouteTableResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putRouteTableResponse.Value.Data.ProvisioningState.ToString()); @@ -149,7 +149,7 @@ public async Task RoutesHopTypeTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/routeTables"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string routeTableName = Recording.GenerateAssetName("azsmnet"); string route1Name = Recording.GenerateAssetName("azsmnet"); string route2Name = Recording.GenerateAssetName("azsmnet"); @@ -170,7 +170,7 @@ public async Task RoutesHopTypeTest() routeTable.Routes.Add(route1); // Put RouteTable - var routeTableContainer = GetRouteTableContainer(resourceGroupName); + var routeTableContainer = resourceGroup.Value.GetRouteTables(); RouteTablesCreateOrUpdateOperation putRouteTableResponseOperation = await routeTableContainer.StartCreateOrUpdateAsync(routeTableName, routeTable); Response putRouteTableResponse = await putRouteTableResponseOperation.WaitForCompletionAsync();; diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/SecurityRuleTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/SecurityRuleTests.cs index 5339427fce382..db1e7ff780615 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/SecurityRuleTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/SecurityRuleTests.cs @@ -39,7 +39,8 @@ public async Task SecurityRuleWithRulesApiTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/networkSecurityGroups"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); + string networkSecurityGroupName = Recording.GenerateAssetName("azsmnet"); string securityRule1 = Recording.GenerateAssetName("azsmnet"); string securityRule2 = Recording.GenerateAssetName("azsmnet"); @@ -66,7 +67,7 @@ public async Task SecurityRuleWithRulesApiTest() }; // Put Nsg - var networkSecurityGroupContainer = GetNetworkSecurityGroupContainer(resourceGroupName); + var networkSecurityGroupContainer = resourceGroup.Value.GetNetworkSecurityGroups(); NetworkSecurityGroupsCreateOrUpdateOperation putNsgResponseOperation = await networkSecurityGroupContainer.StartCreateOrUpdateAsync(networkSecurityGroupName, networkSecurityGroup); Response putNsgResponse = await putNsgResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putNsgResponse.Value.Data.ProvisioningState.ToString()); diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/SubnetTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/SubnetTests.cs index f7efea202b68f..18ad795682123 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/SubnetTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/SubnetTests.cs @@ -39,7 +39,7 @@ public async Task SubnetApiTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/virtualNetworks"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string vnetName = Recording.GenerateAssetName("azsmnet"); string subnet1Name = Recording.GenerateAssetName("azsmnet"); string subnet2Name = Recording.GenerateAssetName("azsmnet"); @@ -58,7 +58,7 @@ public async Task SubnetApiTest() Subnets = { new SubnetData() { Name = subnet1Name, AddressPrefix = "10.0.0.0/24", } } }; - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); var vnetResponse = await putVnetResponseOperation.WaitForCompletionAsync();; // Create a Subnet @@ -103,7 +103,7 @@ public async Task SubnetResourceNavigationLinksTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/virtualNetworks"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string vnetName = Recording.GenerateAssetName("azsmnet"); string subnetName = Recording.GenerateAssetName("azsmnet"); @@ -121,7 +121,7 @@ public async Task SubnetResourceNavigationLinksTest() Subnets = { new SubnetData() { Name = subnetName, AddressPrefix = "10.0.0.0/24", } } }; - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); var vnetResponse = await putVnetResponseOperation.WaitForCompletionAsync();; Response getSubnetResponse = await vnetResponse.Value.GetSubnets().GetAsync(subnetName); diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/VirtualNetworkPeeringTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/VirtualNetworkPeeringTests.cs index 5b482f5da4859..f7010e1f35249 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/VirtualNetworkPeeringTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/VirtualNetworkPeeringTests.cs @@ -40,7 +40,7 @@ public async Task VirtualNetworkPeeringApiTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); var location = "westus"; - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string vnetName = Recording.GenerateAssetName("azsmnet"); string remoteVirtualNetworkName = Recording.GenerateAssetName("azsmnet"); @@ -63,7 +63,7 @@ public async Task VirtualNetworkPeeringApiTest() }; // Put Vnet - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); Response putVnetResponse = await putVnetResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putVnetResponse.Value.Data.ProvisioningState.ToString()); @@ -84,7 +84,7 @@ public async Task VirtualNetworkPeeringApiTest() Response remoteVirtualNetwork = await remoteVirtualNetworkOperation.WaitForCompletionAsync();; // Get Peerings in the vnet - var virtualNetworkPeeringContainer = GetVirtualNetworkContainer(resourceGroupName).Get(vnetName).Value.GetVirtualNetworkPeerings(); + var virtualNetworkPeeringContainer =resourceGroup.Value.GetVirtualNetworks().Get(vnetName).Value.GetVirtualNetworkPeerings(); AsyncPageable listPeeringAP = virtualNetworkPeeringContainer.GetAllAsync(); List listPeering = await listPeeringAP.ToEnumerableAsync(); Assert.IsEmpty(listPeering); diff --git a/sdk/network/Azure.ResourceManager.Network/tests/Tests/VirtualNetworkTests.cs b/sdk/network/Azure.ResourceManager.Network/tests/Tests/VirtualNetworkTests.cs index ce543ad902ea9..bc6b5a4a90637 100644 --- a/sdk/network/Azure.ResourceManager.Network/tests/Tests/VirtualNetworkTests.cs +++ b/sdk/network/Azure.ResourceManager.Network/tests/Tests/VirtualNetworkTests.cs @@ -40,7 +40,7 @@ public async Task VirtualNetworkApiTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/virtualNetworks"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string vnetName = Recording.GenerateAssetName("azsmnet"); string subnet1Name = Recording.GenerateAssetName("azsmnet"); @@ -61,7 +61,7 @@ public async Task VirtualNetworkApiTest() }; // Put Vnet - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); Response putVnetResponse = await putVnetResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putVnetResponse.Value.Data.ProvisioningState.ToString()); @@ -107,7 +107,7 @@ public async Task VirtualNetworkCheckIpAddressAvailabilityTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/virtualNetworks"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string vnetName = Recording.GenerateAssetName("azsmnet"); string subnetName = Recording.GenerateAssetName("azsmnet"); @@ -127,7 +127,7 @@ public async Task VirtualNetworkCheckIpAddressAvailabilityTest() }; // Put Vnet - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); Response putVnetResponse = await putVnetResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putVnetResponse.Value.Data.ProvisioningState.ToString()); @@ -156,7 +156,7 @@ public async Task VirtualNetworkCheckIpAddressAvailabilityTest() } }; - NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await GetNetworkInterfaceContainer(resourceGroupName).StartCreateOrUpdateAsync(nicName, nicParameters); + NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await resourceGroup.Value.GetNetworkInterfaces().StartCreateOrUpdateAsync(nicName, nicParameters); await putNicResponseOperation.WaitForCompletionAsync();; // Check Ip Address availability API @@ -180,7 +180,7 @@ public async Task VirtualNetworkPeeringTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/virtualNetworks"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string vnet1Name = Recording.GenerateAssetName("azsmnet"); string vnet2Name = Recording.GenerateAssetName("azsmnet"); string subnet1Name = Recording.GenerateAssetName("azsmnet"); @@ -202,7 +202,7 @@ public async Task VirtualNetworkPeeringTest() }; // Put Vnet - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnet1Name, vnet); Response putVnetResponse = await putVnetResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putVnetResponse.Value.Data.ProvisioningState.ToString()); @@ -294,7 +294,7 @@ public async Task VirtualNetworkUsageTest() string resourceGroupName = Recording.GenerateAssetName("csmrg"); string location = await NetworkManagementTestUtilities.GetResourceLocation(ResourceManagementClient, "Microsoft.Network/virtualNetworks"); - await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new Resources.Models.ResourceGroup(location)); + var resourceGroup = await CreateResourceGroup(resourceGroupName); string vnetName = Recording.GenerateAssetName("azsmnet"); string subnetName = Recording.GenerateAssetName("azsmnet"); @@ -313,7 +313,7 @@ public async Task VirtualNetworkUsageTest() }; // Put Vnet - var virtualNetworkContainer = GetVirtualNetworkContainer(resourceGroupName); + var virtualNetworkContainer = resourceGroup.Value.GetVirtualNetworks(); VirtualNetworksCreateOrUpdateOperation putVnetResponseOperation = await virtualNetworkContainer.StartCreateOrUpdateAsync(vnetName, vnet); Response putVnetResponse = await putVnetResponseOperation.WaitForCompletionAsync();; Assert.AreEqual("Succeeded", putVnetResponse.Value.Data.ProvisioningState.ToString()); @@ -348,7 +348,7 @@ public async Task VirtualNetworkUsageTest() } }; - var networkInterfaceContainer = GetNetworkInterfaceContainer(resourceGroupName); + var networkInterfaceContainer = resourceGroup.Value.GetNetworkInterfaces(); NetworkInterfacesCreateOrUpdateOperation putNicResponseOperation = await networkInterfaceContainer.StartCreateOrUpdateAsync(nicName, nicParameters); var nicResponse = await putNicResponseOperation.WaitForCompletionAsync();; // Get Vnet usage again