/// <summary> /// Initializes client properties. /// </summary> private void Initialize() { ApplicationGateways = new ApplicationGatewaysOperations(this); ExpressRouteCircuitAuthorizations = new ExpressRouteCircuitAuthorizationsOperations(this); ExpressRouteCircuitPeerings = new ExpressRouteCircuitPeeringsOperations(this); ExpressRouteCircuits = new ExpressRouteCircuitsOperations(this); ExpressRouteServiceProviders = new ExpressRouteServiceProvidersOperations(this); LoadBalancers = new LoadBalancersOperations(this); NetworkInterfaces = new NetworkInterfacesOperations(this); NetworkSecurityGroups = new NetworkSecurityGroupsOperations(this); SecurityRules = new SecurityRulesOperations(this); NetworkWatchers = new NetworkWatchersOperations(this); PacketCaptures = new PacketCapturesOperations(this); PublicIPAddresses = new PublicIPAddressesOperations(this); RouteFilters = new RouteFiltersOperations(this); RouteFilterRules = new RouteFilterRulesOperations(this); RouteTables = new RouteTablesOperations(this); Routes = new RoutesOperations(this); BgpServiceCommunities = new BgpServiceCommunitiesOperations(this); Usages = new UsagesOperations(this); VirtualNetworks = new VirtualNetworksOperations(this); Subnets = new SubnetsOperations(this); VirtualNetworkPeerings = new VirtualNetworkPeeringsOperations(this); VirtualNetworkGateways = new VirtualNetworkGatewaysOperations(this); VirtualNetworkGatewayConnections = new VirtualNetworkGatewayConnectionsOperations(this); LocalNetworkGateways = new LocalNetworkGatewaysOperations(this); BaseUri = new System.Uri("https://management.azure.com"); AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; SerializationSettings = new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List<JsonConverter> { new Iso8601TimeSpanConverter() } }; SerializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings = new JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List<JsonConverter> { new Iso8601TimeSpanConverter() } }; CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); }
public async Task TestNicVirtualMachineReference() { EnsureClientsInitialized(DefaultLocation); ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true); string rgName = Recording.GenerateAssetName(TestPrefix); string asName = Recording.GenerateAssetName("as"); string storageAccountName = Recording.GenerateAssetName(TestPrefix); VirtualMachine inputVM; // Create the resource Group, it might have been already created during StorageAccount creation. var resourceGroup = await ResourceGroupsOperations.CreateOrUpdateAsync( rgName, new ResourceGroup(m_location) { Tags = new Dictionary <string, string>() { { rgName, Recording.UtcNow.ToString("u") } } }); // Create Storage Account, so that both the VMs can share it var storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName); Subnet subnetResponse = await CreateVNET(rgName); NetworkInterface nicResponse = await CreateNIC(rgName, subnetResponse, null); string asetId = await CreateAvailabilitySet(rgName, asName); inputVM = CreateDefaultVMInput(rgName, storageAccountName, imageRef, asetId, nicResponse.Id); string expectedVMReferenceId = Helpers.GetVMReferenceId(m_subId, rgName, inputVM.Name); var createOrUpdateResponse = await WaitForCompletionAsync(await VirtualMachinesOperations.StartCreateOrUpdateAsync( rgName, inputVM.Name, inputVM)); Assert.NotNull(createOrUpdateResponse); var getVMResponse = await VirtualMachinesOperations.GetAsync(rgName, inputVM.Name); //Assert.True( // getVMResponse.Value.AvailabilitySet.Id // .ToLowerInvariant() == asetId.ToLowerInvariant()); ValidateVM(inputVM, getVMResponse, expectedVMReferenceId); var getNicResponse = (await NetworkInterfacesOperations.GetAsync(rgName, nicResponse.Name)).Value; // TODO AutoRest: Recording Passed, but these assertions failed in Playback mode Assert.NotNull(getNicResponse.MacAddress); Assert.NotNull(getNicResponse.Primary); Assert.True(getNicResponse.Primary != null && getNicResponse.Primary.Value); }
/// <summary> /// Initializes client properties. /// </summary> private void Initialize() { LoadBalancers = new LoadBalancersOperations(this); NetworkInterfaces = new NetworkInterfacesOperations(this); PublicIPAddresses = new PublicIPAddressesOperations(this); BaseUri = new System.Uri("https://management.azure.com"); AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; SerializationSettings = new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; SerializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings = new JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); }
/// <summary> /// Initializes client properties. /// </summary> protected override void Initialize() { ApplicationGateways = new ApplicationGatewaysOperations(this); ApplicationSecurityGroups = new ApplicationSecurityGroupsOperations(this); AvailableDelegations = new AvailableDelegationsOperations(this); AvailableResourceGroupDelegations = new AvailableResourceGroupDelegationsOperations(this); AzureFirewalls = new AzureFirewallsOperations(this); AzureFirewallFqdnTags = new AzureFirewallFqdnTagsOperations(this); BastionHosts = new BastionHostsOperations(this); DdosCustomPolicies = new DdosCustomPoliciesOperations(this); DdosProtectionPlans = new DdosProtectionPlansOperations(this); AvailableEndpointServices = new AvailableEndpointServicesOperations(this); ExpressRouteCircuitAuthorizations = new ExpressRouteCircuitAuthorizationsOperations(this); ExpressRouteCircuitPeerings = new ExpressRouteCircuitPeeringsOperations(this); ExpressRouteCircuitConnections = new ExpressRouteCircuitConnectionsOperations(this); PeerExpressRouteCircuitConnections = new PeerExpressRouteCircuitConnectionsOperations(this); ExpressRouteCircuits = new ExpressRouteCircuitsOperations(this); ExpressRouteServiceProviders = new ExpressRouteServiceProvidersOperations(this); ExpressRouteCrossConnections = new ExpressRouteCrossConnectionsOperations(this); ExpressRouteCrossConnectionPeerings = new ExpressRouteCrossConnectionPeeringsOperations(this); ExpressRouteGateways = new ExpressRouteGatewaysOperations(this); ExpressRouteConnections = new ExpressRouteConnectionsOperations(this); ExpressRoutePortsLocations = new ExpressRoutePortsLocationsOperations(this); ExpressRoutePorts = new ExpressRoutePortsOperations(this); ExpressRouteLinks = new ExpressRouteLinksOperations(this); LoadBalancers = new LoadBalancersOperations(this); LoadBalancerBackendAddressPools = new LoadBalancerBackendAddressPoolsOperations(this); LoadBalancerFrontendIPConfigurations = new LoadBalancerFrontendIPConfigurationsOperations(this); InboundNatRules = new InboundNatRulesOperations(this); LoadBalancerLoadBalancingRules = new LoadBalancerLoadBalancingRulesOperations(this); LoadBalancerOutboundRules = new LoadBalancerOutboundRulesOperations(this); LoadBalancerNetworkInterfaces = new LoadBalancerNetworkInterfacesOperations(this); LoadBalancerProbes = new LoadBalancerProbesOperations(this); NatGateways = new NatGatewaysOperations(this); NetworkInterfaces = new NetworkInterfacesOperations(this); NetworkInterfaceIPConfigurations = new NetworkInterfaceIPConfigurationsOperations(this); NetworkInterfaceLoadBalancers = new NetworkInterfaceLoadBalancersOperations(this); NetworkInterfaceTapConfigurations = new NetworkInterfaceTapConfigurationsOperations(this); NetworkProfiles = new NetworkProfilesOperations(this); NetworkSecurityGroups = new NetworkSecurityGroupsOperations(this); SecurityRules = new SecurityRulesOperations(this); DefaultSecurityRules = new DefaultSecurityRulesOperations(this); NetworkWatchers = new NetworkWatchersOperations(this); PacketCaptures = new PacketCapturesOperations(this); ConnectionMonitors = new ConnectionMonitorsOperations(this); Operations = new Operations(this); PrivateEndpoints = new PrivateEndpointsOperations(this); AvailablePrivateEndpointTypes = new AvailablePrivateEndpointTypesOperations(this); PrivateLinkServices = new PrivateLinkServicesOperations(this); PublicIPAddresses = new PublicIPAddressesOperations(this); PublicIPPrefixes = new PublicIPPrefixesOperations(this); RouteFilters = new RouteFiltersOperations(this); RouteFilterRules = new RouteFilterRulesOperations(this); RouteTables = new RouteTablesOperations(this); Routes = new RoutesOperations(this); BgpServiceCommunities = new BgpServiceCommunitiesOperations(this); ServiceEndpointPolicies = new ServiceEndpointPoliciesOperations(this); ServiceEndpointPolicyDefinitions = new ServiceEndpointPolicyDefinitionsOperations(this); ServiceTags = new ServiceTagsOperations(this); Usages = new UsagesOperations(this); VirtualNetworks = new VirtualNetworksOperations(this); Subnets = new SubnetsOperations(this); ResourceNavigationLinks = new ResourceNavigationLinksOperations(this); ServiceAssociationLinks = new ServiceAssociationLinksOperations(this); VirtualNetworkPeerings = new VirtualNetworkPeeringsOperations(this); VirtualNetworkGateways = new VirtualNetworkGatewaysOperations(this); VirtualNetworkGatewayConnections = new VirtualNetworkGatewayConnectionsOperations(this); LocalNetworkGateways = new LocalNetworkGatewaysOperations(this); VirtualNetworkTaps = new VirtualNetworkTapsOperations(this); VirtualWans = new VirtualWansOperations(this); VpnSites = new VpnSitesOperations(this); VpnSiteLinks = new VpnSiteLinksOperations(this); VpnSitesConfiguration = new VpnSitesConfigurationOperations(this); VirtualHubs = new VirtualHubsOperations(this); HubVirtualNetworkConnections = new HubVirtualNetworkConnectionsOperations(this); VpnGateways = new VpnGatewaysOperations(this); VpnConnections = new VpnConnectionsOperations(this); VpnSiteLinkConnections = new VpnSiteLinkConnectionsOperations(this); VpnLinkConnections = new VpnLinkConnectionsOperations(this); P2sVpnServerConfigurations = new P2sVpnServerConfigurationsOperations(this); P2sVpnGateways = new P2sVpnGatewaysOperations(this); WebApplicationFirewallPolicies = new WebApplicationFirewallPoliciesOperations(this); BaseUri = new System.Uri("https://management.azure.com"); AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; SerializationSettings = new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; SerializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings = new JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); }
public async Task TestEffectiveRouteAndAcls() { EnsureClientsInitialized(DefaultLocation); ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true); string rgName = Recording.GenerateAssetName(TestPrefix); string asName = Recording.GenerateAssetName("as"); string storageAccountName = Recording.GenerateAssetName(TestPrefix); VirtualMachine inputVM; // Create the resource Group, it might have been already created during StorageAccount creation. var resourceGroup = await ResourceGroupsOperations.CreateOrUpdateAsync( rgName, new ResourceGroup(m_location) { Tags = new Dictionary <string, string>() { { rgName, Recording.UtcNow.ToString("u") } } }); // Create Storage Account, so that both the VMs can share it var storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName); Subnet subnetResponse = await CreateVNET(rgName); NetworkSecurityGroup nsgResponse = await CreateNsg(rgName); NetworkInterface nicResponse = await CreateNIC(rgName, subnetResponse, null, null, nsgResponse); string asetId = await CreateAvailabilitySet(rgName, asName); inputVM = CreateDefaultVMInput(rgName, storageAccountName, imageRef, asetId, nicResponse.Id); string expectedVMReferenceId = Helpers.GetVMReferenceId(m_subId, rgName, inputVM.Name); var createOrUpdateResponse = await WaitForCompletionAsync(await VirtualMachinesOperations.StartCreateOrUpdateAsync( rgName, inputVM.Name, inputVM)); Assert.NotNull(createOrUpdateResponse); var getVMResponse = (await VirtualMachinesOperations.GetAsync(rgName, inputVM.Name)).Value; //Assert.True( // getVMResponse.AvailabilitySet.Id // .ToLowerInvariant() == asetId.ToLowerInvariant()); ValidateVM(inputVM, getVMResponse, expectedVMReferenceId); var getNicResponse = (await NetworkInterfacesOperations.GetAsync(rgName, nicResponse.Name)).Value; // TODO AutoRest: Recording Passed, but these assertions failed in Playback mode Assert.NotNull(getNicResponse.MacAddress); Assert.NotNull(getNicResponse.Primary); Assert.True(getNicResponse.Primary != null && getNicResponse.Primary.Value); // Get Effective RouteTable var getEffectiveRouteTable = (await WaitForCompletionAsync(await NetworkInterfacesOperations.StartGetEffectiveRouteTableAsync(rgName, nicResponse.Name))).Value; Assert.NotNull(getEffectiveRouteTable); //Assert.AreNotEqual(0, getEffectiveRouteTable.Value.Count); Assert.AreEqual(getEffectiveRouteTable.Value[0].Source, EffectiveRouteSource.Default); Assert.AreEqual(getEffectiveRouteTable.Value[0].State, EffectiveRouteState.Active); // Get Effecting NSG var getEffectiveNSGresponse = (await WaitForCompletionAsync(await NetworkInterfacesOperations.StartListEffectiveNetworkSecurityGroupsAsync(rgName, nicResponse.Name.ToString()))).Value; Assert.NotNull(getEffectiveNSGresponse); Assert.AreNotEqual(0, getEffectiveNSGresponse.Value.Count); Assert.NotNull(getEffectiveNSGresponse.Value[0].Association); Assert.NotNull(getEffectiveNSGresponse.Value[0].Association.NetworkInterface); Assert.Null(getEffectiveNSGresponse.Value[0].Association.Subnet); Assert.AreEqual(getEffectiveNSGresponse.Value[0].Association.NetworkInterface.Id, nicResponse.Id); Assert.NotNull(getEffectiveNSGresponse.Value[0].NetworkSecurityGroup); Assert.AreEqual(getEffectiveNSGresponse.Value[0].NetworkSecurityGroup.Id, nsgResponse.Id); Assert.NotNull(getEffectiveNSGresponse.Value[0].EffectiveSecurityRules); Assert.AreNotEqual(0, getEffectiveNSGresponse.Value[0].EffectiveSecurityRules.Count); Assert.NotNull(getEffectiveNSGresponse.Value[0].EffectiveSecurityRules[0].Access); Assert.NotNull(getEffectiveNSGresponse.Value[0].EffectiveSecurityRules[0].DestinationAddressPrefix); Assert.NotNull(getEffectiveNSGresponse.Value[0].EffectiveSecurityRules[0].DestinationPortRange); Assert.NotNull(getEffectiveNSGresponse.Value[0].EffectiveSecurityRules[0].SourceAddressPrefix); Assert.NotNull(getEffectiveNSGresponse.Value[0].EffectiveSecurityRules[0].SourcePortRange); Assert.NotNull(getEffectiveNSGresponse.Value[0].EffectiveSecurityRules[0].Priority); Assert.NotNull(getEffectiveNSGresponse.Value[0].EffectiveSecurityRules[0].Name); Assert.NotNull(getEffectiveNSGresponse.Value[0].EffectiveSecurityRules[0].ExpandedDestinationAddressPrefix); Assert.NotNull(getEffectiveNSGresponse.Value[0].EffectiveSecurityRules[0].ExpandedSourceAddressPrefix); }
public async Task TestMultiIpConfigForMultiNICVM() { EnsureClientsInitialized(DefaultLocation); ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true); string rgName = Recording.GenerateAssetName(TestPrefix); string asName = Recording.GenerateAssetName("as"); string storageAccountName = Recording.GenerateAssetName(TestPrefix); VirtualMachine inputVM; // Create the resource Group, it might have been already created during StorageAccount creation. var resourceGroup = await ResourceGroupsOperations.CreateOrUpdateAsync( rgName, new ResourceGroup(m_location) { Tags = new Dictionary <string, string>() { { rgName, Recording.UtcNow.ToString("u") } } }); // Create Storage Account, so that both the VMs can share it var storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName); Subnet subnetResponse = await CreateVNET(rgName); string nicname1 = Recording.GenerateAssetName(null); string nicname2 = Recording.GenerateAssetName(null); NetworkInterface nicResponse1 = await CreateMultiIpConfigNIC(rgName, subnetResponse, nicname1); NetworkInterface nicResponse2 = await CreateMultiIpConfigNIC(rgName, subnetResponse, nicname2); string asetId = await CreateAvailabilitySet(rgName, asName); inputVM = CreateDefaultVMInput(rgName, storageAccountName, imageRef, asetId, nicResponse1.Id); inputVM.HardwareProfile.VmSize = VirtualMachineSizeTypes.StandardA4; inputVM.NetworkProfile.NetworkInterfaces[0].Primary = false; inputVM.NetworkProfile.NetworkInterfaces.Add(new NetworkInterfaceReference { Id = nicResponse2.Id, Primary = true }); string expectedVMReferenceId = Helpers.GetVMReferenceId(m_subId, rgName, inputVM.Name); var createOrUpdateResponse = await WaitForCompletionAsync(await VirtualMachinesOperations.StartCreateOrUpdateAsync(rgName, inputVM.Name, inputVM)); var getVMResponse = (await VirtualMachinesOperations.GetAsync(rgName, inputVM.Name)).Value; //Assert.True( // getVMResponse.AvailabilitySet.Id // .ToLowerInvariant() == asetId.ToLowerInvariant()); ValidateVM(inputVM, getVMResponse, expectedVMReferenceId); var getNicResponse1 = (await NetworkInterfacesOperations.GetAsync(rgName, nicResponse1.Name)).Value; // TODO AutoRest: Recording Passed, but these assertions failed in Playback mode Assert.NotNull(getNicResponse1.MacAddress); Assert.NotNull(getNicResponse1.Primary); Assert.True(getNicResponse1.Primary != null && !getNicResponse1.Primary.Value); var getNicResponse2 = (await NetworkInterfacesOperations.GetAsync(rgName, nicResponse2.Name)).Value; // TODO AutoRest: Recording Passed, but these assertions failed in Playback mode Assert.NotNull(getNicResponse2.MacAddress); Assert.NotNull(getNicResponse2.Primary); Assert.True(getNicResponse2.Primary != null && getNicResponse2.Primary.Value); // multi CA Assertions Assert.AreEqual(2, getNicResponse1.IpConfigurations.Count); Assert.AreEqual(2, getNicResponse2.IpConfigurations.Count); Assert.IsTrue(getNicResponse1.IpConfigurations.Where(x => x.Primary == true).Count() == 1); Assert.IsTrue(getNicResponse2.IpConfigurations.Where(x => x.Primary == true).Count() == 1); //Assert.Single(getNicResponse1.IpConfigurations.Where(x => x.Primary == true)); //Assert.Single(getNicResponse2.IpConfigurations.Where(x => x.Primary == true)); }