示例#1
0
        public static void CompareManagedNetwork(ManagedNetworkModel mn1, ManagedNetworkModel mn2)
        {
            Assert.Equal(mn1.Location, mn2.Location);

            CompareScope(mn1.Scope, mn2.Scope);

            if (mn1.Connectivity == null)
            {
                if (mn2.Connectivity != null)
                {
                    Assert.Equal(0, mn2.Connectivity.Groups.Count);
                    Assert.Equal(0, mn2.Connectivity.Peerings.Count);
                }
            }
            else
            {
                CompareConnectivityCollection(mn1.Connectivity, mn2.Connectivity);
            }
        }
示例#2
0
        public void ManagedNetworkGroupTest()
        {
            using (var context = MockContext.Start(this.GetType().FullName))
            {
                #region Initialization
                this.client          = context.GetServiceClient <ManagedNetworkManagementClient>();
                this.resourcesClient = context.GetServiceClient <ResourceManagementClient>();

                string resourceGroupName = TestUtilities.GenerateName("MNCRP_RSG");
                string location          = "Central US";

                ResourceGroup rsg;
                try
                {
                    rsg = this.resourcesClient.ResourceGroups.Get(resourceGroupName);
                }
                catch
                {
                    rsg = this.resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroupName,
                                                                             new ResourceGroup
                    {
                        Location = location
                    });
                }
                Assert.Equal(rsg.Name, resourceGroupName);
                #endregion

                #region Create managedNetwork
                string managedNetworkName          = TestUtilities.GenerateName("myManagedNetwork");
                ManagedNetworkModel managedNetwork = new ManagedNetworkModel()
                {
                    Location = location,
                    Scope    = new Scope()
                    {
                        VirtualNetworks = new List <ResourceId>()
                        {
                            new ResourceId()
                            {
                                Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNCRG/providers/Microsoft.Network/virtualnetworks/testvnet"
                            },
                            new ResourceId()
                            {
                                Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNCRG/providers/Microsoft.Network/virtualnetworks/testvnet2"
                            },
                            new ResourceId()
                            {
                                Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNCRG/providers/Microsoft.Network/virtualnetworks/Spoke9"
                            }
                        },
                    }
                };
                // Put ManagedNetwork
                this.client.ManagedNetworks.CreateOrUpdate(managedNetwork, resourceGroupName, managedNetworkName);
                // Create Connectivity Group
                string managedNetworkGroupName          = TestUtilities.GenerateName("myGroup");
                ManagedNetworkGroup managedNetworkGroup = new ManagedNetworkGroup()
                {
                    Location        = location,
                    VirtualNetworks = new List <ResourceId>()
                    {
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNCRG/providers/Microsoft.Network/virtualnetworks/testvnet2"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNCRG/providers/Microsoft.Network/virtualnetworks/Spoke9"
                        }
                    }
                };
                // Put Connectivity Group
                ManagedNetworkGroup putConnectivityGroupResponse = this.client.ManagedNetworkGroups.CreateOrUpdate(managedNetworkGroup, resourceGroupName, managedNetworkName, managedNetworkGroupName);
                #endregion

                #region Create peeringPolicy
                string     peeringPolicyName = TestUtilities.GenerateName("hubAndSpoke");
                ResourceId hub = new ResourceId()
                {
                    Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNCRG/providers/Microsoft.Network/virtualnetworks/testvnet"
                };

                var spokes = new List <ResourceId>
                {
                    new ResourceId()
                    {
                        Id = putConnectivityGroupResponse.Id
                    },
                };

                ManagedNetworkPeeringPolicyProperties managedNetworkPeeringPolicyProperties = new ManagedNetworkPeeringPolicyProperties
                {
                    Type   = "HubAndSpokeTopology",
                    Hub    = hub,
                    Spokes = spokes
                };

                ManagedNetworkPeeringPolicy peeringPolicy = new ManagedNetworkPeeringPolicy
                {
                    Location   = location,
                    Properties = managedNetworkPeeringPolicyProperties
                };
                #endregion

                // Put PeeringPolicy
                ManagedNetworkPeeringPolicy putPeeringPolicyResult = this.client.ManagedNetworkPeeringPolicies.CreateOrUpdate(peeringPolicy, resourceGroupName, managedNetworkName, peeringPolicyName);
                Assert.NotNull(putPeeringPolicyResult);
                Comparator.ComparePeeringPolicy(peeringPolicy, putPeeringPolicyResult);

                // Get PeeringPolicy
                ManagedNetworkPeeringPolicy getPeeringPolicyResult = this.client.ManagedNetworkPeeringPolicies.Get(resourceGroupName, managedNetworkName, peeringPolicyName);
                Comparator.ComparePeeringPolicy(peeringPolicy, getPeeringPolicyResult);

                //Get PeeringPolicy from ManagedNetwork
                ManagedNetworkModel getManagedNetworkResponse = this.client.ManagedNetworks.Get(resourceGroupName, managedNetworkName);
                Comparator.ComparePeeringPolicy(peeringPolicy, getManagedNetworkResponse.Connectivity.Peerings[0]);

                //List PeeringPolicy from ManagedNetworkm
                var listPeeringPolicyResponse = this.client.ManagedNetworkPeeringPolicies.ListByManagedNetwork(resourceGroupName, managedNetworkName);
                Assert.Single(listPeeringPolicyResponse);

                //Delete PeeringPolicy
                this.client.ManagedNetworkPeeringPolicies.Delete(resourceGroupName, managedNetworkName, peeringPolicyName);
            }
        }
        public void ManagedNetworkGroupTest()
        {
            using (var context = MockContext.Start(this.GetType().FullName))
            {
                #region Initialization
                this.client          = context.GetServiceClient <ManagedNetworkManagementClient>();
                this.resourcesClient = context.GetServiceClient <ResourceManagementClient>();

                string resourceGroupName = TestUtilities.GenerateName("MNCRP_RSG");
                string location          = "West US";

                ResourceGroup rsg;
                try
                {
                    rsg = this.resourcesClient.ResourceGroups.Get(resourceGroupName);
                }
                catch
                {
                    rsg = this.resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroupName,
                                                                             new ResourceGroup
                    {
                        Location = location
                    });
                }
                Assert.Equal(rsg.Name, resourceGroupName);
                #endregion

                #region Create managedNetwork
                string managedNetworkName          = TestUtilities.GenerateName("myManagedNetwork");
                ManagedNetworkModel managedNetwork = new ManagedNetworkModel()
                {
                    Location = location,
                    Scope    = new Scope()
                    {
                        VirtualNetworks = new List <ResourceId>()
                        {
                            new ResourceId()
                            {
                                Id = "subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNCRG/providers/Microsoft.Network/virtualnetworks/testvnet"
                            },
                            new ResourceId()
                            {
                                Id = "subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNCRG/providers/Microsoft.Network/virtualnetworks/testvnet2"
                            },
                            new ResourceId()
                            {
                                Id = "subscriptions/6bb4a28a-db84-4e8a-b1dc-fabf7bd9f0b2/resourceGroups/MNCRG/providers/Microsoft.Network/virtualnetworks/NewTestVNet"
                            }
                        },
                    }
                };
                // Put ManagedNetwork
                ManagedNetworkModel putManagedNetworkResponse = this.client.ManagedNetworks.CreateOrUpdate(managedNetwork, resourceGroupName, managedNetworkName);
                #endregion

                string managedNetworkGroupName          = TestUtilities.GenerateName("myGroup");
                ManagedNetworkGroup managedNetworkGroup = new ManagedNetworkGroup()
                {
                    VirtualNetworks = new List <ResourceId>()
                    {
                        new ResourceId()
                        {
                            Id = "subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNCRG/providers/Microsoft.Network/virtualnetworks/testvnet2"
                        },
                        new ResourceId()
                        {
                            Id = "subscriptions/6bb4a28a-db84-4e8a-b1dc-fabf7bd9f0b2/resourceGroups/MNCRG/providers/Microsoft.Network/virtualnetworks/NewTestVNet"
                        }
                    }
                };
                ManagedNetworkGroup putManagedNetworkGroup = this.client.ManagedNetworkGroups.CreateOrUpdate(managedNetworkGroup, resourceGroupName, managedNetworkName, managedNetworkGroupName);
                Comparator.CompareManagedNetworkGroup(managedNetworkGroup, putManagedNetworkGroup);

                ManagedNetworkGroup getManagedNetworkGroup = this.client.ManagedNetworkGroups.Get(resourceGroupName, managedNetworkName, managedNetworkGroupName);
                Comparator.CompareManagedNetworkGroup(managedNetworkGroup, getManagedNetworkGroup);

                ManagedNetworkModel getManagedNetworkResponse = this.client.ManagedNetworks.Get(resourceGroupName, managedNetworkName);
                Comparator.CompareManagedNetworkGroup(managedNetworkGroup, getManagedNetworkResponse.Connectivity.Groups[0]);

                var listManagedNetworkGroupResponse = this.client.ManagedNetworkGroups.ListByManagedNetwork(resourceGroupName, managedNetworkName);
                Assert.Single(listManagedNetworkGroupResponse);
            }
        }
        public void ManagedNetworkTest()
        {
            using (var context = MockContext.Start(this.GetType().FullName))
            {
                #region Initialization
                this.client          = context.GetServiceClient <ManagedNetworkManagementClient>();
                this.resourcesClient = context.GetServiceClient <ResourceManagementClient>();

                string resourceGroupName = TestUtilities.GenerateName("MNCRP_RSG");
                string location          = "Central US";

                ResourceGroup rsg;
                try
                {
                    rsg = this.resourcesClient.ResourceGroups.Get(resourceGroupName);
                }
                catch
                {
                    rsg = this.resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroupName,
                                                                             new ResourceGroup
                    {
                        Location = location
                    });
                }
                Assert.Equal(rsg.Name, resourceGroupName);
                #endregion

                #region Create managedNetwork
                string managedNetworkName          = TestUtilities.GenerateName("myManagedNetwork");
                ManagedNetworkModel managedNetwork = new ManagedNetworkModel()
                {
                    Location = location,
                    Scope    = new Scope()
                    {
                        ManagementGroups = new List <ResourceId>(),
                        Subscriptions    = new List <ResourceId>(),
                        VirtualNetworks  = new List <ResourceId>()
                        {
                            new ResourceId()
                            {
                                Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNCRG/providers/Microsoft.Network/virtualnetworks/testvnet"
                            }
                        },
                        Subnets = new List <ResourceId>(),
                    }
                };
                #endregion

                // Put ManagedNetwork
                ManagedNetworkModel putManagedNetworkResponse = this.client.ManagedNetworks.CreateOrUpdate(managedNetwork, resourceGroupName, managedNetworkName);
                Assert.NotNull(putManagedNetworkResponse);
                Comparator.CompareManagedNetwork(managedNetwork, putManagedNetworkResponse);


                // Get ManagedNetwork
                ManagedNetworkModel getManagedNetworkResponse = this.client.ManagedNetworks.Get(resourceGroupName, managedNetworkName);
                Comparator.CompareManagedNetwork(managedNetwork, getManagedNetworkResponse);

                var listManagedNetworkResponse = this.client.ManagedNetworks.ListBySubscription();
                Assert.NotEmpty(listManagedNetworkResponse);

                this.client.ManagedNetworks.Delete(resourceGroupName, managedNetworkName);
                listManagedNetworkResponse = this.client.ManagedNetworks.ListByResourceGroup(resourceGroupName);
                Assert.Empty(listManagedNetworkResponse);
            }
        }
示例#5
0
        public void Mesh()
        {
            using (var context = MockContext.Start(this.GetType().FullName))
            {
                #region Initialization
                this.client          = context.GetServiceClient <ManagedNetworkManagementClient>();
                this.resourcesClient = context.GetServiceClient <ResourceManagementClient>();
                string resourceGroupName = "MNC-Portal";
                string location          = "Central US";

                ResourceGroup rsg;
                try
                {
                    rsg = this.resourcesClient.ResourceGroups.Get(resourceGroupName);
                }
                catch
                {
                    rsg = this.resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroupName,
                                                                             new ResourceGroup
                    {
                        Location = location
                    });
                }
                Assert.Equal(rsg.Name, resourceGroupName);
                #endregion

                #region Create managedNetwork
                string managedNetworkName = "SDK_ManagedNetwork_Mesh2";
                Scope  mNScope            = new Scope()
                {
                    VirtualNetworks = new List <ResourceId>()
                    {
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-PowerShell/providers/Microsoft.Network/virtualnetworks/Mesh1"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-PowerShell/providers/Microsoft.Network/virtualnetworks/Mesh2"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-PowerShell/providers/Microsoft.Network/virtualnetworks/Mesh3"
                        }
                    }
                };

                ManagedNetworkModel managedNetwork = new ManagedNetworkModel()
                {
                    Location = location,
                    Scope    = mNScope
                };

                ManagedNetworkModel putManagedNetworkResponse = this.client.ManagedNetworks.CreateOrUpdate(managedNetwork, resourceGroupName, managedNetworkName);
                #endregion
                string managedNetworkGroupName = "SDK_MeshGroup";

                ManagedNetworkGroup managedNetworkGroup = new ManagedNetworkGroup()
                {
                    Location        = location,
                    VirtualNetworks = new List <ResourceId>()
                    {
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-PowerShell/providers/Microsoft.Network/virtualnetworks/Mesh1"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-PowerShell/providers/Microsoft.Network/virtualnetworks/Mesh2"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-PowerShell/providers/Microsoft.Network/virtualnetworks/Mesh3"
                        }
                    }
                };


                // Put Connectivity Group
                ManagedNetworkGroup putManagedNetworkGroupResponse = this.client.ManagedNetworkGroups.CreateOrUpdate(managedNetworkGroup, resourceGroupName, managedNetworkName, managedNetworkGroupName);

                #region Create peeringPolicy
                string peeringPolicyName = "SDK_MeshPolicy";

                string managedNetworkPeeringPolicyType = "MeshTopology";
                var    mesh = new List <ResourceId>
                {
                    new ResourceId()
                    {
                        Id = putManagedNetworkGroupResponse.Id
                    },
                };


                ManagedNetworkPeeringPolicyProperties managedNetworkPeeringPolicyProperties = new ManagedNetworkPeeringPolicyProperties
                {
                    Type = managedNetworkPeeringPolicyType,
                    Mesh = mesh
                };

                ManagedNetworkPeeringPolicy peeringPolicy = new ManagedNetworkPeeringPolicy
                {
                    Location   = location,
                    Properties = managedNetworkPeeringPolicyProperties
                };
                #endregion
                // Put PeeringPolicy
                ManagedNetworkPeeringPolicy putPeeringPolicyResult = this.client.ManagedNetworkPeeringPolicies.CreateOrUpdate(peeringPolicy, resourceGroupName, managedNetworkName, peeringPolicyName);
            }
        }
示例#6
0
        public void Clear()
        {
            using (var context = MockContext.Start(this.GetType().FullName))
            {
                #region Initialization
                this.client          = context.GetServiceClient <ManagedNetworkManagementClient>();
                this.resourcesClient = context.GetServiceClient <ResourceManagementClient>();
                string resourceGroupName = "MNC-Portal";
                string location          = "Central US";

                ResourceGroup rsg;
                try
                {
                    rsg = this.resourcesClient.ResourceGroups.Get(resourceGroupName);
                }
                catch
                {
                    rsg = this.resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroupName,
                                                                             new ResourceGroup
                    {
                        Location = location
                    });
                }
                Assert.Equal(rsg.Name, resourceGroupName);
                #endregion
                #region Create managedNetwork
                string managedNetworkName = "myManagedNetwork";

                Scope scope = new Scope()
                {
                    VirtualNetworks = new List <ResourceId>()
                    {
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-PowerShell/providers/Microsoft.Network/virtualnetworks/Mesh1"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-PowerShell/providers/Microsoft.Network/virtualnetworks/Mesh2"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-PowerShell/providers/Microsoft.Network/virtualnetworks/Mesh3"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-PowerShell/providers/Microsoft.Network/virtualnetworks/Mesh4"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-PowerShell/providers/Microsoft.Network/virtualnetworks/Mesh5"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke1"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke2"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke3"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke4"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke5"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke6"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke7"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke8"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke9"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke10"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke11"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke12"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke13"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke14"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke15"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Hub"
                        },
                    }
                };

                ManagedNetworkModel managedNetwork = new ManagedNetworkModel()
                {
                    Location = location,
                    Scope    = scope
                };

                ManagedNetworkModel putManagedNetworkResponse = this.client.ManagedNetworks.CreateOrUpdate(managedNetwork, resourceGroupName, managedNetworkName);
                #endregion

                this.client.ManagedNetworks.Delete(resourceGroupName, managedNetworkName);
            }
        }
示例#7
0
        public void HubSpoke()
        {
            var mode             = System.Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
            var connectionstring = System.Environment.GetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION");

            using (var context = MockContext.Start(this.GetType().FullName))
            {
                #region Initialization
                this.client          = context.GetServiceClient <ManagedNetworkManagementClient>();
                this.resourcesClient = context.GetServiceClient <ResourceManagementClient>();
                string resourceGroupName = "MNC-Portal";
                string location          = "Central US";

                ResourceGroup rsg;
                try
                {
                    rsg = this.resourcesClient.ResourceGroups.Get(resourceGroupName);
                }
                catch
                {
                    rsg = this.resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroupName,
                                                                             new ResourceGroup
                    {
                        Location = location
                    });
                }
                Assert.Equal(rsg.Name, resourceGroupName);
                #endregion

                #region Create managedNetwork
                string managedNetworkName = "Portal_ManagedNetwork118";

                Scope scope = new Scope()
                {
                    VirtualNetworks = new List <ResourceId>()
                    {
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke11"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke12"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke13"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke14"
                        }
                    }
                };

                IDictionary <string, string> tags = new Dictionary <string, string>();
                tags["SampleKey"] = "SampleValue";
                ManagedNetworkModel managedNetwork = new ManagedNetworkModel()
                {
                    Location = location,
                    Scope    = scope,
                    Tags     = tags
                };

                ManagedNetworkModel putManagedNetworkResponse = this.client.ManagedNetworks.CreateOrUpdate(managedNetwork, resourceGroupName, managedNetworkName);
                #endregion



                string managedNetworkGroupName          = "Portal_SpokeGroup3";
                ManagedNetworkGroup managedNetworkGroup = new ManagedNetworkGroup()
                {
                    Location        = location,
                    VirtualNetworks = new List <ResourceId>()
                    {
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke12"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke11"
                        },
                        new ResourceId()
                        {
                            Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke13"
                        }
                    }
                };
                // Put Connectivity Group
                ManagedNetworkGroup putManagedNetworkGroupResponse = this.client.ManagedNetworkGroups.CreateOrUpdate(managedNetworkGroup, resourceGroupName, managedNetworkName, managedNetworkGroupName);



                #region Create peeringPolicy
                string     peeringPolicyName = "SDK_MeshPolicy3";
                ResourceId hub = new ResourceId()
                {
                    Id = "/subscriptions/18ba8369-92e4-4d70-8b1e-937660bde798/resourceGroups/MNC-Portal/providers/Microsoft.Network/virtualNetworks/Spoke14"
                };

                var spokes = new List <ResourceId>
                {
                    new ResourceId()
                    {
                        Id = putManagedNetworkGroupResponse.Id
                    },
                };

                ManagedNetworkPeeringPolicyProperties managedNetworkPeeringPolicyProperties = new ManagedNetworkPeeringPolicyProperties
                {
                    Type   = "HubAndSpokeTopology",
                    Hub    = hub,
                    Spokes = spokes
                };

                ManagedNetworkPeeringPolicy peeringPolicy = new ManagedNetworkPeeringPolicy
                {
                    Location   = location,
                    Properties = managedNetworkPeeringPolicyProperties
                };
                #endregion

                // Put PeeringPolicy
                ManagedNetworkPeeringPolicy putPeeringPolicyResult = this.client.ManagedNetworkPeeringPolicies.CreateOrUpdate(peeringPolicy, resourceGroupName, managedNetworkName, peeringPolicyName);
            }
        }
示例#8
0
 /// <summary>
 /// The Put ManagedNetworks operation creates/updates a Managed Network
 /// Resource, specified by resource group and Managed Network name
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='managedNetwork'>
 /// Parameters supplied to the create/update a Managed Network Resource
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='managedNetworkName'>
 /// The name of the Managed Network.
 /// </param>
 public static ManagedNetworkModel CreateOrUpdate(this IManagedNetworksOperations operations, ManagedNetworkModel managedNetwork, string resourceGroupName, string managedNetworkName)
 {
     return(operations.CreateOrUpdateAsync(managedNetwork, resourceGroupName, managedNetworkName).GetAwaiter().GetResult());
 }
示例#9
0
 /// <summary>
 /// The Put ManagedNetworks operation creates/updates a Managed Network
 /// Resource, specified by resource group and Managed Network name
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='managedNetwork'>
 /// Parameters supplied to the create/update a Managed Network Resource
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='managedNetworkName'>
 /// The name of the Managed Network.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ManagedNetworkModel> CreateOrUpdateAsync(this IManagedNetworksOperations operations, ManagedNetworkModel managedNetwork, string resourceGroupName, string managedNetworkName, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(managedNetwork, resourceGroupName, managedNetworkName, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }