public void CreateAppendProviderAndChild()
        {
            var id = new ResourceIdentifier("/subscriptions/0c2f6471-1bf0-4dda-aec3-cb9272f09575/resourceGroups/myRg");

            id = id.AppendProviderResource("Microsoft.Compute", "virtualMachines", "myVm");
            id = id.AppendChildResource("children", "myChild");
        }
Exemplo n.º 2
0
        public void Sort()
        {
            List <ResourceIdentifier> list    = new List <ResourceIdentifier>();
            ResourceIdentifier        id      = new ResourceIdentifier(TrackedResourceId);
            ResourceIdentifier        childId = id.AppendChildResource("myChild", "myChildName");

            list.Add(childId);
            list.Add(id);
            Assert.AreEqual(childId.Name, list[0].Name);
            list.Sort();
            Assert.AreEqual(id.Name, list[0].Name);
        }
Exemplo n.º 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;
 }
        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();
        }