Пример #1
0
        public NetworkInterfaceBasicStack()
        {
            var tags = new InputMap <string> {
                { "env", "dev" }
            };

            var rg = new ResourceGroupBuilder("rg1")
                     .Name("rg1")
                     .Location("westeurope")
                     .Build();
            var vnet = new VNetBuilder("vnet1")
                       .Location("westeurope")
                       .ResourceGroup(rg.Name)
                       .Name("vnet1")
                       .AddressSpace("172.16.0.0/24")
                       .Build();
            var subnet1 = new SubnetBuilder("subnet1")
                          .Parent(vnet)
                          .Name("subnet1")
                          .ResourceGroup(rg.Name)
                          .InVNet(vnet.Name)
                          .AddressPrefix("172.16.0.0/26")
                          .Build();
            var subnet2 = new SubnetBuilder("subnet2")
                          .Parent(vnet)
                          .Name("subnet2")
                          .ResourceGroup(rg.Name)
                          .InVNet(vnet.Name)
                          .AddressPrefix("172.16.0.64/26")
                          .Build();
            var nsg = new NetworkSecurityGroupBuilder("nsg1")
                      .Location("westeurope")
                      .ResourceGroup(rg.Name)
                      .Name("nsg1")
                      .Build();
            var nic1 = new NetworkInterfaceBuilder("nic1")
                       .Name("nic1")
                       .ResourceGroup(rg.Name)
                       .Build();
            var nic2 = new NetworkInterfaceBuilder("nic2")
                       .Name("nic2")
                       .ResourceGroup(rg.Name)
                       .Location("westeurope")
                       .AddDynamicIPConfiguration("ipconfig1", subnet2.Id, false)
                       .AddStaticIPConfiguration("ipconfig2", subnet2.Id, "172.16.0.69", true)
                       .EnableAcceleratedNetworking(true)
                       .EnableIPForwarding(true)
                       .NetworkSecurityGroup(nsg.Id)
                       .ExtendedLocation("edgelocation")
                       .DnsSettings("dnsLabel", "192.32.0.0")
                       .Tags(tags)
                       .Build();
        }
 public NetworkSecurityGroupBasicStack()
 {
     var rg = new ResourceGroupBuilder("rg1")
              .Name("rg1")
              .Location("westeurope")
              .Build();
     var tags = new InputMap <string> {
         { "env", "dev" }
     };
     var nsg = new NetworkSecurityGroupBuilder("nsg1")
               .Location("westeurope")
               .ResourceGroup(rg.Name)
               .Name("nsg1")
               .Tags(tags)
               .Build();
 }
Пример #3
0
        public SecurityRuleBasicStack()
        {
            var rg = new ResourceGroupBuilder("rg1")
                     .Name("rg1")
                     .Location("westeurope")
                     .Build();

            var nsg = new NetworkSecurityGroupBuilder("nsg1")
                      .Location("westeurope")
                      .ResourceGroup(rg.Name)
                      .Name("nsg1")
                      .Build();
            var asg1 = new ApplicationSecurityGroupBuilder("asg1")
                       .Location("westeurope")
                       .ResourceGroup(rg.Name)
                       .Name("asg1")
                       .Build();
            var asg2 = new ApplicationSecurityGroupBuilder("asg2")
                       .Location("westeurope")
                       .ResourceGroup(rg.Name)
                       .Name("asg2")
                       .Build();
            var sr1 = new SecurityRuleBuilder("sr1")
                      .Name("sr1")
                      .NsgName(nsg.Name)
                      .Direction(SecurityRuleDirection.Inbound)
                      .Access(SecurityRuleAccess.Allow)
                      .ResourceGroup(rg.Name)
                      .AnySourcePorts()
                      .AnyDestinationPorts()
                      .AnySourceTraffic()
                      .AnyDestinationTraffic()
                      .Protocol(SecurityRuleProtocol.Asterisk)
                      .Build();

            var sr2 = new SecurityRuleBuilder("sr2")
                      .Name("sr2")
                      .NsgName(nsg.Name)
                      .Direction(SecurityRuleDirection.Outbound)
                      .Access(SecurityRuleAccess.Deny)
                      .Priority(101)
                      .ResourceGroup(rg.Name)
                      .AnySourcePorts()
                      .AnyDestinationPorts()
                      .Protocol(SecurityRuleProtocol.Tcp)
                      .Description("test2")
                      .SourceIPAddresses("172.68.0.0/28", "172.68.0.16/28")
                      .DestinationIPAddresses("172.68.0.0/28", "172.68.0.16/28")
                      .Build();

            var sr3 = new SecurityRuleBuilder("sr3")
                      .Name("sr3")
                      .NsgName(nsg.Name)
                      .Direction(SecurityRuleDirection.Outbound)
                      .Access(SecurityRuleAccess.Deny)
                      .Priority(101)
                      .ResourceGroup(rg.Name)
                      .SourcePortRanges("22", "80-1024")
                      .DestinationPortRanges("22", "80-1024")
                      .Protocol(SecurityRuleProtocol.Tcp)
                      .Description("test3")
                      .SourceASGs(asg1.Id)
                      .DestinationASGs(asg2.Id)
                      .Build();
        }