Ejemplo n.º 1
0
        private bool DeletePeering(MockContext context, string name, string resourceGroupName)
        {
            this.client = context.GetServiceClient <PeeringManagementClient>();
            PeeringModel peer = null;

            try
            {
                this.client.Peerings.Delete(resourceGroupName, name);
                peer = this.client.Peerings.Get(resourceGroupName, name);
                if (peer == null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Assert.Null(peer);
                Assert.NotNull(ex.Message);
                return(true);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The create exchange peering.
        /// </summary>
        /// <param name="asn">
        /// The asn.
        /// </param>
        /// <returns>
        /// The <see cref="PeeringModel"/>.
        /// </returns>
        private PeeringModel CreateExchangePeeringModel(int asn = 65000)
        {
            // create resource group
            var resourceGroup = this.CreateResourceGroup();

            // Create Asn
            var subId = this.CreatePeerAsn(asn, $"AS{asn}", isApproved: true);

            // Create Exchange Peering
            var ipAddress          = int.Parse(MockServer.GetVariable("ipAddress", this.random.Next(150, 190).ToString()));
            var exchangeConnection = new ExchangeConnection
            {
                ConnectionIdentifier = Guid.NewGuid().ToString(),
                PeeringDBFacilityId  = 99999,
                BgpSession           = new Microsoft.Azure.Management.Peering.Models.BgpSession()
                {
                    PeerSessionIPv4Address  = $"10.12.97.{ipAddress}",
                    MaxPrefixesAdvertisedV4 = 20000
                }
            };
            SubResource asnReference = new SubResource(subId);
            var         exchangePeeringProperties = new PeeringPropertiesExchange(
                new List <ExchangeConnection>(),
                asnReference);

            exchangePeeringProperties.Connections.Add(exchangeConnection);
            var peeringModel = new PeeringModel
            {
                PeeringLocation = "Seattle",
                Sku             = new PeeringSku("Basic_Exchange_Free"),
                Location        = "centralus",
                Exchange        = exchangePeeringProperties,
                Kind            = "Exchange",
                Tags            = new Dictionary <string, string>
                {
                    { TestUtilities.GenerateName("tfs_"), "Active" }
                }
            };
            var name = $"exchangepeering{asn}";

            try
            {
                var result  = this.Client.Peerings.CreateOrUpdate(resourceGroup.Name, name, peeringModel);
                var peering = this.Client.Peerings.Get(resourceGroup.Name, name);
                Assert.NotNull(peering);
                Assert.Equal(name, peering.Name);
                return(peering);
            }
            catch (Exception ex)
            {
                Assert.Contains("NotFound", ex.Message);
            }
            return(null);
        }
Ejemplo n.º 3
0
        public void CreateExchangePeering()
        {
            using (var context = MockContext.Start(this.GetType().FullName))
            {
                this.client = context.GetServiceClient <PeeringManagementClient>();

                //Create a Resource Group
                this.resourcesClient = context.GetServiceClient <ResourceManagementClient>();
                var rgname        = TestUtilities.GenerateName("res");
                var resourceGroup = resourcesClient.ResourceGroups.CreateOrUpdate(
                    rgname,
                    new ResourceGroup
                {
                    Location = "centralus"
                });


                int asn = 65000;

                //Create Exchange Peering
                var exchangeConnection = new ExchangeConnection
                {
                    PeeringDBFacilityId = 26,
                    BgpSession          = new Microsoft.Azure.Management.Peering.Models.BgpSession()
                    {
                        PeerSessionIPv4Address  = $"80.249.208.{this.random.Next(1, 254)}",
                        MaxPrefixesAdvertisedV4 = 20000
                    }
                };
                SubResource asnReference = new SubResource(this.client.PeerAsns.Get($"Contoso{asn}").Id);
                var         exchangePeeringProperties = new PeeringPropertiesExchange(new List <ExchangeConnection>(), asnReference);
                exchangePeeringProperties.Connections.Add(exchangeConnection);
                var peeringModel = new PeeringModel
                {
                    PeeringLocation = "Amsterdam",
                    Sku             = new PeeringSku("Basic_Exchange_Free"),
                    Location        = "centralus",
                    Exchange        = exchangePeeringProperties,
                    Kind            = "Exchange"
                };
                var name    = $"exchangepeering1022";
                var result  = this.client.Peerings.CreateOrUpdate(rgname, name, peeringModel);
                var peering = this.client.Peerings.Get(rgname, name);
                Assert.NotNull(peering);
                Assert.Equal(name, peering.Name);
            }
        }
Ejemplo n.º 4
0
        public void CreateDirectPeering()
        {
            using (var context = MockContext.Start(this.GetType().FullName))
            {
                this.client = context.GetServiceClient <PeeringManagementClient>();

                //Create a Resource Group
                this.resourcesClient = context.GetServiceClient <ResourceManagementClient>();
                var rgname        = TestUtilities.GenerateName("res");
                var resourceGroup = resourcesClient.ResourceGroups.CreateOrUpdate(
                    rgname,
                    new ResourceGroup
                {
                    Location = "centralus"
                });

                //Create Direct Peering
                var directConnection = new DirectConnection
                {
                    BandwidthInMbps     = 10000,
                    PeeringDBFacilityId = 63,
                    BgpSession          = new Microsoft.Azure.Management.Peering.Models.BgpSession()
                    {
                        SessionPrefixV4         = this.CreateIpv4Address(true),
                        MaxPrefixesAdvertisedV4 = 20000
                    }
                };

                SubResource asnReference            = new SubResource(this.client.PeerAsns.Get($"Contoso{65000}").Id);
                var         directPeeringProperties = new PeeringPropertiesDirect(new List <DirectConnection>(), false, asnReference);
                directPeeringProperties.Connections.Add(directConnection);
                var peeringModel = new PeeringModel
                {
                    PeeringLocation = "Amsterdam",
                    Sku             = new PeeringSku("Basic_Direct_Free"),
                    Direct          = directPeeringProperties,
                    Location        = "centralus",
                    Kind            = "Direct"
                };
                var name    = $"directpeering3103";
                var result  = this.client.Peerings.CreateOrUpdate(rgname, name, peeringModel);
                var peering = this.client.Peerings.Get(rgname, name);
                Assert.NotNull(peering);
                Assert.Equal(name, peering.Name);
            }
        }
Ejemplo n.º 5
0
 public void CreateGetListAndDeleteRegisteredAns()
 {
     using (MockContext context = MockContext.Start(this.GetType().FullName))
     {
         this.MockClients(context);
         PeeringModel peering           = null;
         var          asn               = int.Parse(MockServer.GetVariable("asnInteger", this.random.Next(1, 65000).ToString()));
         var          registeredAsnName = TestUtilities.GenerateName("_asn");
         try
         {
             peering = this.CreateExchangePeeringModel(asn);
             var registeredAsn = new PeeringRegisteredAsn {
                 Asn = asn
             };
             var resource = this.Client.RegisteredAsns.CreateOrUpdate(
                 this.GetResourceGroup(peering.Id),
                 this.GetPeeringName(peering.Id),
                 $"{peering.Name}{registeredAsnName}",
                 registeredAsn.Asn);
             Assert.Null(resource);
             resource = this.Client.RegisteredAsns.Get(
                 this.GetResourceGroup(peering.Id),
                 this.GetPeeringName(peering.Id),
                 $"{peering.Name}{registeredAsnName}");
             Assert.Null(resource);
             var list = this.Client.RegisteredAsns.ListByPeering(
                 this.GetResourceGroup(peering.Id),
                 this.GetPeeringName(peering.Id));
             Assert.Null(list);
             this.Client.RegisteredAsns.Delete(
                 this.GetResourceGroup(peering.Id),
                 this.GetPeeringName(peering.Id),
                 $"{peering.Name}{registeredAsnName}");
             resource = this.Client.RegisteredAsns.Get(
                 this.GetResourceGroup(peering.Id),
                 this.GetPeeringName(peering.Id),
                 $"{peering.Name}{registeredAsnName}");
             Assert.Null(resource);
         }
         finally
         {
             Assert.True(this.DeletePeering(peering.Name, this.GetResourceGroup(peering.Id)));
             Assert.True(this.DeletePeerAsn($"AS{asn}"));
         }
     }
 }
Ejemplo n.º 6
0
 public void CreateGetListAndDeleteRegisteredPrefix()
 {
     using (MockContext context = MockContext.Start(this.GetType().FullName))
     {
         this.MockClients(context);
         PeeringModel peering    = null;
         var          asn        = int.Parse(TestUtilities.GenerateName("0"));
         var          prefixName = TestUtilities.GenerateName("_prefix");
         try
         {
             peering = this.CreateExchangePeeringModel(asn);
             var prefix = new PeeringRegisteredPrefix {
                 Prefix = "10.10.0.0/24"
             };
             var resource = this.Client.RegisteredPrefixes.CreateOrUpdate(
                 this.GetResourceGroup(peering.Id),
                 this.GetPeeringName(peering.Id),
                 $"{peering.Name}{prefixName}",
                 prefix.Prefix);
             Assert.Null(resource);
             resource = this.Client.RegisteredPrefixes.Get(
                 this.GetResourceGroup(peering.Id),
                 this.GetPeeringName(peering.Id),
                 $"{peering.Name}{prefixName}");
             Assert.Null(resource);
             var list = this.Client.RegisteredPrefixes.ListByPeering(
                 this.GetResourceGroup(peering.Id),
                 this.GetPeeringName(peering.Id));
             Assert.Null(list);
             this.Client.RegisteredPrefixes.Delete(
                 this.GetResourceGroup(peering.Id),
                 this.GetPeeringName(peering.Id),
                 $"{peering.Name}{prefixName}");
             resource = this.Client.RegisteredPrefixes.Get(
                 this.GetResourceGroup(peering.Id),
                 this.GetPeeringName(peering.Id),
                 $"{peering.Name}{prefixName}");
             Assert.Null(resource);
         }
         finally
         {
             Assert.True(this.DeletePeering(peering.Name, this.GetResourceGroup(peering.Id)));
             Assert.True(this.DeletePeerAsn($"AS{asn}"));
         }
     }
 }
Ejemplo n.º 7
0
 public void CreateExchangePeering()
 {
     using (MockContext context = MockContext.Start(this.GetType().FullName))
     {
         this.MockClients(context);
         PeeringModel peering = null;
         var          asn     = int.Parse(TestUtilities.GenerateName("0"));
         try
         {
             peering = this.CreateExchangePeeringModel(asn);
         }
         catch (Exception ex)
         {
             Assert.Contains("NotFound", ex.Message);
         }
         finally
         {
             Assert.True(this.DeletePeering(peering.Name, this.GetResourceGroup(peering.Id)));
             Assert.True(this.DeletePeerAsn($"AS{asn}"));
         }
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// The delete peering.
        /// </summary>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="resourceGroupName">
        /// The resource group name.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private bool DeletePeering(string name, string resourceGroupName)
        {
            PeeringModel peering = null;

            try
            {
                this.Client.Peerings.Delete(resourceGroupName, name);
                peering = this.Client.Peerings.Get(resourceGroupName, name);
                if (peering == null || peering.ProvisioningState == "Deleting")
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                Assert.Null(peering);
                Assert.NotNull(ex.Message);
                Assert.True(this.DeleteResourceGroup(resourceGroupName));
                return(true);
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates a new peering or updates an existing peering with the specified
 /// name under the given subscription and resource group.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='peeringName'>
 /// The name of the peering.
 /// </param>
 /// <param name='peering'>
 /// The properties needed to create or update a peering.
 /// </param>
 public static PeeringModel CreateOrUpdate(this IPeeringsOperations operations, string resourceGroupName, string peeringName, PeeringModel peering)
 {
     return(operations.CreateOrUpdateAsync(resourceGroupName, peeringName, peering).GetAwaiter().GetResult());
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates a new peering or updates an existing peering with the specified
 /// name under the given subscription and resource group.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='peeringName'>
 /// The name of the peering.
 /// </param>
 /// <param name='peering'>
 /// The properties needed to create or update a peering.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <PeeringModel> CreateOrUpdateAsync(this IPeeringsOperations operations, string resourceGroupName, string peeringName, PeeringModel peering, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, peeringName, peering, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Ejemplo n.º 11
0
        public void CreateExchangePeering()
        {
            using (var context = MockContext.Start(this.GetType()))
            {
                this.client = context.GetServiceClient <PeeringManagementClient>();

                //Create a Resource Group
                this.resourcesClient = context.GetServiceClient <ResourceManagementClient>();
                var rgname        = TestUtilities.GenerateName("res");
                var resourceGroup = resourcesClient.ResourceGroups.CreateOrUpdate(
                    rgname,
                    new ResourceGroup
                {
                    Location = "centralus"
                });

                //Create Asn
                int asn   = 65000;
                var subId = this.CreatePeerAsn(context, asn, $"AS{asn}", isApproved: true);


                //Create Exchange Peering
                var exchangeConnection = new ExchangeConnection
                {
                    ConnectionIdentifier = Guid.NewGuid().ToString(),
                    PeeringDBFacilityId  = 99999,
                    BgpSession           = new Microsoft.Azure.Management.Peering.Models.BgpSession()
                    {
                        PeerSessionIPv4Address  = $"10.12.97.{this.random.Next(150, 190)}",
                        MaxPrefixesAdvertisedV4 = 20000
                    }
                };
                SubResource asnReference = new SubResource(subId);
                var         exchangePeeringProperties = new PeeringPropertiesExchange(new List <ExchangeConnection>(), asnReference);
                exchangePeeringProperties.Connections.Add(exchangeConnection);
                var peeringModel = new PeeringModel
                {
                    PeeringLocation = "Seattle",
                    Sku             = new PeeringSku("Basic_Exchange_Free"),
                    Location        = "centralus",
                    Exchange        = exchangePeeringProperties,
                    Kind            = "Exchange",
                    Tags            = new Dictionary <string, string> {
                        { TestUtilities.GenerateName("tfs_"), "Active" }
                    }
                };
                var name = $"exchangepeering1022";
                try
                {
                    var result  = this.client.Peerings.CreateOrUpdate(rgname, name, peeringModel);
                    var peering = this.client.Peerings.Get(rgname, name);
                    Assert.NotNull(peering);
                    Assert.Equal(name, peering.Name);
                }
                catch (Exception ex)
                {
                    Assert.Contains("NotFound", ex.Message);
                }
                finally
                {
                    Assert.True(this.DeletePeering(context, name, rgname));
                    Assert.True(this.DeletePeerAsn(context, $"AS{asn}"));
                    Assert.True(this.DeleteResourceGroup(context, rgname));
                }
            }
        }
Ejemplo n.º 12
0
        public void CreateDirectPeering()
        {
            using (var context = MockContext.Start(this.GetType()))
            {
                this.client = context.GetServiceClient <PeeringManagementClient>();

                //Create a Resource Group
                this.resourcesClient = context.GetServiceClient <ResourceManagementClient>();
                var rgname        = TestUtilities.GenerateName("res");
                var resourceGroup = resourcesClient.ResourceGroups.CreateOrUpdate(
                    rgname,
                    new ResourceGroup
                {
                    Location = "centralus"
                });

                //Create Direct Peering
                var directConnection = new DirectConnection
                {
                    ConnectionIdentifier   = Guid.NewGuid().ToString(),
                    BandwidthInMbps        = 10000,
                    PeeringDBFacilityId    = 99999,
                    SessionAddressProvider = SessionAddressProvider.Peer,
                    UseForPeeringService   = false,
                    BgpSession             = new Microsoft.Azure.Management.Peering.Models.BgpSession()
                    {
                        SessionPrefixV4         = this.CreateIpv4Address(true),
                        MaxPrefixesAdvertisedV4 = 20000
                    }
                };

                //Create Asn
                int asn   = 65003;
                var subId = this.CreatePeerAsn(context, asn, $"AS{asn}", isApproved: true);

                SubResource asnReference            = new SubResource(subId);
                var         directPeeringProperties = new PeeringPropertiesDirect(new List <DirectConnection>(), false, asnReference, DirectPeeringType.Edge);
                directPeeringProperties.Connections.Add(directConnection);
                var peeringModel = new PeeringModel
                {
                    PeeringLocation = "Seattle",
                    Sku             = new PeeringSku("Basic_Direct_Free"),
                    Direct          = directPeeringProperties,
                    Location        = "centralus",
                    Kind            = "Direct"
                };
                var name = $"directpeering3103";
                try
                {
                    var result  = this.client.Peerings.CreateOrUpdate(rgname, name, peeringModel);
                    var peering = this.client.Peerings.Get(rgname, name);
                    Assert.NotNull(peering);
                }
                catch (Exception ex)
                {
                    Assert.Contains("NotFound", ex.Message);
                }
                finally
                {
                    Assert.True(this.DeletePeering(context, name, rgname));
                    Assert.True(this.DeletePeerAsn(context, $"AS{asn}"));
                    //Assert.True(this.DeleteResourceGroup(context, rgname));
                }
            }
        }
Ejemplo n.º 13
0
        public void CreateGetListAndDeleteRegisteredAsns()
        {
            using (MockContext context = MockContext.Start(this.GetType().FullName))
            {
                this.MockClients(context);

                // Create a Resource Group
                var rgname = this.CreateResourceGroup().Name;

                PeeringModel peering   = null;
                var          asn       = int.Parse(MockServer.GetVariable("asnInteger", this.random.Next(1, 65000).ToString()));
                var          peerAsnId = this.CreatePeerAsn(asn, $"AS{asn}", isApproved: true);
                var          peerAsn   = this.Client.PeerAsns.Get(this.GetPeerAsnName(peerAsnId));
                try
                {
                    var directPeeringProperties = new PeeringPropertiesDirect(
                        new List <DirectConnection>(),
                        true,
                        new SubResource(peerAsnId),
                        DirectPeeringType.IxRs);
                    var locations = this.Client.PeeringLocations.List("Direct", DirectPeeringType.Edge);
                    var loc       = locations.FirstOrDefault(x => x.Name == "Seattle");

                    // Create Direct Peering
                    var directConnection = new DirectConnection
                    {
                        ConnectionIdentifier = Guid.NewGuid().ToString(),
                        BandwidthInMbps      = 10000,
                        PeeringDBFacilityId  =
                            loc.Direct.PeeringFacilities
                            .FirstOrDefault(x => x.PeeringDBFacilityId == 99999)
                            ?.PeeringDBFacilityId,
                        SessionAddressProvider = SessionAddressProvider.Microsoft,
                        UseForPeeringService   = true
                    };
                    directPeeringProperties.Connections.Add(directConnection);
                    var peeringModel = new PeeringModel
                    {
                        PeeringLocation = loc.Name,
                        Sku             = new PeeringSku("Premium_Direct_Free"),
                        Direct          = directPeeringProperties,
                        Location        = loc.AzureRegion,
                        Kind            = "Direct"
                    };
                    var name = TestUtilities.GenerateName("direct_");
                    try
                    {
                        var result = this.Client.Peerings.CreateOrUpdate(rgname, name, peeringModel);
                        peering = this.Client.Peerings.Get(rgname, name);
                        Assert.NotNull(peering);
                    }
                    catch (Exception ex)
                    {
                        Assert.Contains("NotFound", ex.Message);
                    }

                    var rgName            = this.GetResourceGroup(peering.Id);
                    var pName             = this.GetPeeringName(peering.Id);
                    var registeredAsnName = $"{peering.Name}_{peerAsn.PeerAsnProperty}";
                    var resource          = this.Client.RegisteredAsns.CreateOrUpdate(
                        rgName,
                        pName,
                        registeredAsnName,
                        peerAsn.PeerAsnProperty);
                    Assert.NotNull(resource);
                    resource = this.Client.RegisteredAsns.Get(rgName, pName, registeredAsnName);
                    Assert.NotNull(resource);
                    var list = this.Client.RegisteredAsns.ListByPeering(rgname, pName);
                    Assert.NotNull(list);
                    this.Client.RegisteredAsns.Delete(
                        rgName,
                        pName,
                        registeredAsnName);
                    resource = this.Client.RegisteredAsns.Get(
                        rgName,
                        pName,
                        registeredAsnName);
                    Assert.NotNull(resource);
                }
                finally
                {
                    Assert.True(this.DeletePeering(peering.Name, this.GetResourceGroup(peering.Id)));
                    Assert.True(this.DeletePeerAsn($"AS{asn}"));
                }
            }
        }
Ejemplo n.º 14
0
        public void CreateGetListAndDeleteRegisteredPrefix()
        {
            using (MockContext context = MockContext.Start(this.GetType().FullName))
            {
                this.MockClients(context);
                PeeringModel peering    = null;
                var          asn        = int.Parse(TestUtilities.GenerateName("0"));
                var          prefixName = TestUtilities.GenerateName("prefix_");
                try
                {
                    // Create a Resource Group
                    var rgname = this.CreateResourceGroup().Name;

                    // Create Asn
                    var subId = this.CreatePeerAsn(asn, $"AS{asn}", isApproved: true, peerName: "FooBar");

                    // Set prefix
                    var prefix = new PeeringRegisteredPrefix {
                        Prefix = CreateIpv4Address(true)
                    };

                    SubResource asnReference            = new SubResource(subId);
                    var         directPeeringProperties = new PeeringPropertiesDirect(
                        new List <DirectConnection>(),
                        true,
                        asnReference,
                        DirectPeeringType.Edge);
                    var locations = this.Client.PeeringLocations.List("Direct", DirectPeeringType.Edge);
                    var loc       = locations.FirstOrDefault(x => x.Name == "Seattle");

                    // Create Direct Peering
                    var directConnection = new DirectConnection
                    {
                        ConnectionIdentifier = Guid.NewGuid().ToString(),
                        BandwidthInMbps      = 10000,
                        PeeringDBFacilityId  =
                            loc.Direct.PeeringFacilities.FirstOrDefault(x => x.PeeringDBFacilityId == 99999)
                            ?.PeeringDBFacilityId,
                        SessionAddressProvider = SessionAddressProvider.Peer,
                        BgpSession             = new BgpSession
                        {
                            SessionPrefixV4 = prefix.Prefix, MaxPrefixesAdvertisedV4 = 20000
                        },
                        UseForPeeringService = true
                    };

                    directPeeringProperties.Connections.Add(directConnection);
                    var peeringModel = new PeeringModel
                    {
                        PeeringLocation = loc.Name,
                        Sku             = new PeeringSku("Premium_Direct_Free"),
                        Direct          = directPeeringProperties,
                        Location        = loc.AzureRegion,
                        Kind            = "Direct"
                    };
                    var name = TestUtilities.GenerateName("direct_");
                    try
                    {
                        var result = this.Client.Peerings.CreateOrUpdate(rgname, name, peeringModel);
                        peering = this.Client.Peerings.Get(rgname, name);
                        Assert.NotNull(peering);
                    }
                    catch (Exception ex)
                    {
                        Assert.Contains("NotFound", ex.Message);
                    }

                    var resourceGroupName    = this.GetResourceGroup(peering?.Id);
                    var peeringName          = this.GetPeeringName(peering?.Id);
                    var registeredPrefixName = $"{peering?.Name}{prefixName}";

                    var resource = this.Client.RegisteredPrefixes.CreateOrUpdate(
                        resourceGroupName,
                        peeringName,
                        registeredPrefixName,
                        this.CreateIpv4Address(true));
                    Assert.NotNull(resource.PeeringServicePrefixKey);
                    resource = this.Client.RegisteredPrefixes.Get(
                        resourceGroupName,
                        peeringName,
                        registeredPrefixName);
                    Assert.NotNull(resource.PeeringServicePrefixKey);
                    var list = this.Client.RegisteredPrefixes.ListByPeering(resourceGroupName, peeringName);
                    Assert.NotNull(list.FirstOrDefault()?.PeeringServicePrefixKey);
                    this.Client.RegisteredPrefixes.Delete(
                        resourceGroupName,
                        peeringName,
                        registeredPrefixName);
                    try
                    {
                        resource = this.Client.RegisteredPrefixes.Get(
                            resourceGroupName,
                            peeringName,
                            registeredPrefixName);
                    }
                    catch (Exception ex)
                    {
                        Assert.NotNull(ex.Message);
                    }
                }
                finally
                {
                    Assert.True(this.DeletePeering(peering.Name, this.GetResourceGroup(peering.Id)));
                    Assert.True(this.DeletePeerAsn($"AS{asn}"));
                }
            }
        }