///GENMHASH:359B78C1848B4A526D723F29D8C8C558:149EB760CEBAD953681C8A653E657563 protected async override Task <Models.VirtualNetworkGatewayInner> CreateInnerAsync(CancellationToken cancellationToken = default(CancellationToken)) { var tasks = new List <Task>(); VirtualNetworkGatewayIPConfigurationImpl defaultIPConfig = EnsureDefaultIPConfig(); if (defaultIPConfig != null && defaultIPConfig.PublicIPAddressId() == null) { // If public ip not specified, then create a default PIP Task pipTask = Task.Run(async() => { var publicIP = await EnsureDefaultPipDefinition().CreateAsync(cancellationToken); defaultIPConfig.WithExistingPublicIPAddress(publicIP); }); tasks.Add(pipTask); } // Determine if default VNet should be created if (defaultIPConfig.SubnetName() == null) { // But if default IP config does not have a subnet specified, then create a VNet Task networkTask = Task.Run(async() => { var network = await creatableNetwork.CreateAsync(cancellationToken); //... and assign the created VNet to the default IP config defaultIPConfig.WithExistingSubnet(network, GATEWAY_SUBNET); }); tasks.Add(networkTask); } await Task.WhenAll(tasks.ToArray()); return(await Manager.Inner.VirtualNetworkGateways.CreateOrUpdateAsync(ResourceGroupName, Name, Inner, cancellationToken)); }
///GENMHASH:E22C6898BD46DFC7E4BA741E47A25FCD:130D5B3A30C34F066046287000EF7300 internal VirtualNetworkGatewayImpl WithConfig(VirtualNetworkGatewayIPConfigurationImpl config) { if (config != null) { ipConfigs[config.Name()] = config; } return(this); }
///GENMHASH:6EBB2EF319A59A13633F5A0954A40EF9:5E1483B1F2AC819468AF87C89BCDB29C private VirtualNetworkGatewayIPConfigurationImpl EnsureDefaultIPConfig() { VirtualNetworkGatewayIPConfigurationImpl ipConfig = (VirtualNetworkGatewayIPConfigurationImpl)DefaultIPConfiguration(); if (ipConfig == null) { string name = SdkContext.RandomResourceName("ipcfg", 11); ipConfig = DefineIPConfiguration(name); ipConfig.Attach(); } return(ipConfig); }
///GENMHASH:F1D809E72100A32A88F33ADB2356893B:83A6444D89474D9E0A81484A4E69AE59 private void InitializeIPConfigsFromInner() { ipConfigs = new Dictionary <string, IVirtualNetworkGatewayIPConfiguration>(); var inners = this.Inner.IpConfigurations; if (inners != null) { foreach (var inner in inners) { var config = new VirtualNetworkGatewayIPConfigurationImpl(inner, this); ipConfigs[inner.Name] = config; } } }