Пример #1
0
        AzureFirewall IOperationSource <AzureFirewall> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = AzureFirewallData.DeserializeAzureFirewallData(document.RootElement);

            return(new AzureFirewall(_armClient, data));
        }
Пример #2
0
        internal static AzureFirewallListResult DeserializeAzureFirewallListResult(JsonElement element)
        {
            Optional <IReadOnlyList <AzureFirewallData> > value = default;
            Optional <string> nextLink = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <AzureFirewallData> array = new List <AzureFirewallData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(AzureFirewallData.DeserializeAzureFirewallData(item));
                    }
                    value = array;
                    continue;
                }
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
            }
            return(new AzureFirewallListResult(Optional.ToList(value), nextLink.Value));
        }
Пример #3
0
 public async Task<AzureFirewall> CreateFirewallAsync()
 {
     AzureFirewallData firewallData = new AzureFirewallData();
     firewallData.Location = Location.WestUS2;
     firewallData.IpConfigurations.Add(new AzureFirewallIPConfiguration()
     {
         Name = "fwpip",
         PublicIPAddress = new WritableSubResource() { Id = _publicIPAddressIdentifier },
         Subnet = new WritableSubResource() { Id = _networkIdentifier.AppendChildResource("subnets", "AzureFirewallSubnet") },
     });
     var firewallLro = await (await _resourceGroup.GetAzureFirewalls().CreateOrUpdateAsync(_firewallName, firewallData)).WaitForCompletionAsync();
     return firewallLro.Value;
 }
Пример #4
0
        public async Task <AzureFirewall> CreateFirewall()
        {
            AzureFirewallData firewallData = new AzureFirewallData();

            firewallData.Location = Location.WestUS2;
            firewallData.IpConfigurations.Add(new AzureFirewallIPConfiguration()
            {
                Name            = "fwpip",
                PublicIPAddress = new Models.SubResource()
                {
                    Id = _publicIPAddressIdentifier
                },
                Subnet = new Models.SubResource()
                {
                    Id = _networkIdentifier.ToString() + "/subnets/AzureFirewallSubnet"
                },
            });
            var firewallLro = await(await _resourceGroup.GetAzureFirewalls().CreateOrUpdateAsync(_firewallName, firewallData)).WaitForCompletionAsync();

            return(firewallLro.Value);
        }
        public async Task GlobalSetUp()
        {
            Subscription subscription = await GlobalClient.GetDefaultSubscriptionAsync();

            var rgLro = await subscription.GetResourceGroups().CreateOrUpdateAsync(true, SessionRecording.GenerateAssetName("FirewallPolicyRG-"), new ResourceGroupData(AzureLocation.WestUS2));

            ResourceGroup rg = rgLro.Value;

            _resourceGroupIdentifier = rg.Id;

            VirtualNetworkData vnetData = new VirtualNetworkData()
            {
                Location     = AzureLocation.WestUS2,
                AddressSpace = new AddressSpace()
                {
                    AddressPrefixes = { "10.26.0.0/16", }
                },
                Subnets =
                {
                    new SubnetData()
                    {
                        Name = "Default", AddressPrefix = "10.26.1.0/26",
                    },
                    new SubnetData()
                    {
                        Name = "AzureFirewallSubnet", AddressPrefix = "10.26.2.0/26",
                    },
                },
            };
            var vnetLro = await rg.GetVirtualNetworks().CreateOrUpdateAsync(true, SessionRecording.GenerateAssetName("vnet-"), vnetData);

            _network           = vnetLro.Value;
            _networkIdentifier = _network.Id;

            PublicIPAddressData ipData = new PublicIPAddressData()
            {
                Location = AzureLocation.WestUS2,
                PublicIPAllocationMethod = IPAllocationMethod.Static,
                Sku = new PublicIPAddressSku()
                {
                    Name = PublicIPAddressSkuName.Standard
                },
            };
            var ipLro = await rg.GetPublicIPAddresses().CreateOrUpdateAsync(true, SessionRecording.GenerateAssetName("publicIp-"), ipData);

            _publicIPAddress           = ipLro.Value;
            _publicIPAddressIdentifier = _publicIPAddress.Id;

            AzureFirewallData firewallData = new AzureFirewallData();

            firewallData.Location = AzureLocation.WestUS2;
            firewallData.IPConfigurations.Add(new AzureFirewallIPConfiguration()
            {
                Name            = "fwpip",
                PublicIPAddress = new WritableSubResource()
                {
                    Id = _publicIPAddressIdentifier
                },
                Subnet = new WritableSubResource()
                {
                    Id = _networkIdentifier.AppendChildResource("subnets", "AzureFirewallSubnet")
                },
            });
            var firewallLro = await rg.GetAzureFirewalls().CreateOrUpdateAsync(true, SessionRecording.GenerateAssetName("firewall-"), firewallData);

            _firewall           = firewallLro.Value;
            _firewallIdentifier = _firewall.Id;

            await StopSessionRecordingAsync();
        }