public async Task ClearChallengeCacheforRecord()
        {
            if (Mode == RecordedTestMode.Record || Mode == RecordedTestMode.Playback)
            {
                Initialize();
            }
            _subscription = await ArmClient.GetDefaultSubscriptionAsync();

            resourceGroup = (await CreateResourceGroup(Recording.GenerateAssetName("pe_rg")));
        }
Esempio n. 2
0
 protected NetworkInterfaceCollection GetNetworkInterfaceCollection(Resources.ResourceGroupResource resourceGroup)
 {
     return(resourceGroup.GetNetworkInterfaces());
 }
Esempio n. 3
0
 protected VirtualNetworkCollection GetVirtualNetworkCollection(Resources.ResourceGroupResource resourceGroup)
 {
     return(resourceGroup.GetVirtualNetworks());
 }
Esempio n. 4
0
 protected LoadBalancerCollection GetLoadBalancerCollection(Resources.ResourceGroupResource resourceGroup)
 {
     return(resourceGroup.GetLoadBalancers());
 }
Esempio n. 5
0
        public async Task <ExpressRouteCircuitResource> UpdateDefaultExpressRouteCircuitWithIpv6MicrosoftPeering(Resources.ResourceGroupResource resourceGroup, string circuitName)
        {
            var iPv6Peering = new IPv6ExpressRouteCircuitPeeringConfig()
            {
                PrimaryPeerAddressPrefix   = ExpressRouteTests.MS_PrimaryPrefix_V6,
                SecondaryPeerAddressPrefix = ExpressRouteTests.MS_SecondaryPrefix_V6,
                MicrosoftPeeringConfig     = new ExpressRouteCircuitPeeringConfig()
                {
                    AdvertisedPublicPrefixes =
                    {
                        ExpressRouteTests.MS_PublicPrefix_V6
                    },
                    LegacyMode = Convert.ToInt32(true)
                },
            };

            var peering = new ExpressRouteCircuitPeeringData()
            {
                Name              = ExpressRoutePeeringType.MicrosoftPeering.ToString(),
                PeeringType       = ExpressRoutePeeringType.MicrosoftPeering,
                PeerASN           = Convert.ToInt32(ExpressRouteTests.MS_PeerASN),
                VlanId            = Convert.ToInt32(ExpressRouteTests.MS_VlanId),
                IPv6PeeringConfig = iPv6Peering
            };

            var circuitCollection = resourceGroup.GetExpressRouteCircuits();
            Operation <ExpressRouteCircuitPeeringResource> peerOperation = await circuitCollection.Get(circuitName).Value.GetExpressRouteCircuitPeerings().CreateOrUpdateAsync(WaitUntil.Completed, ExpressRouteTests.Peering_Microsoft, peering);

            Response <ExpressRouteCircuitPeeringResource> peerResponse = await peerOperation.WaitForCompletionAsync();

            Assert.AreEqual("Succeeded", peerResponse.Value.Data.ProvisioningState.ToString());
            Response <ExpressRouteCircuitResource> getCircuitResponse = await circuitCollection.GetAsync(circuitName);

            return(getCircuitResponse);
        }
Esempio n. 6
0
        // TODO: we should try to create using template after new `Azure.ResourceManager.Resource` is available
        //public async Task CreateVm(
        //    string resourceGroupName,
        //    string location,
        //    string virtualMachineName,
        //    string storageAccountName,
        //    string networkInterfaceName,
        //    string networkSecurityGroupName,
        //    string diagnosticsStorageAccountName,
        //    string deploymentName,
        //    string adminPassword)
        //{
        //    string deploymentParams = "{" +
        //        "\"resourceGroupName\": {\"value\": \"" + resourceGroupName + "\"}," +
        //        "\"location\": {\"value\": \"" + location + "\"}," +
        //        "\"virtualMachineName\": { \"value\": \"" + virtualMachineName + "\"}," +
        //        "\"virtualMachineSize\": { \"value\": \"Standard_DS1_v2\"}," +
        //        "\"adminUsername\": { \"value\": \"netanalytics32\"}," +
        //        "\"storageAccountName\": { \"value\": \"" + storageAccountName + "\"}," +
        //        "\"routeTableName\": { \"value\": \"" + resourceGroupName + "RT\"}," +
        //        "\"virtualNetworkName\": { \"value\": \"" + resourceGroupName + "-vnet\"}," +
        //        "\"networkInterfaceName\": { \"value\": \"" + networkInterfaceName + "\"}," +
        //        "\"networkSecurityGroupName\": { \"value\": \"" + networkSecurityGroupName + "\"}," +
        //        "\"adminPassword\": { \"value\": \"" + adminPassword + "\"}," +
        //        "\"storageAccountType\": { \"value\": \"Premium_LRS\"}," +
        //        "\"diagnosticsStorageAccountName\": { \"value\": \"" + diagnosticsStorageAccountName + "\"}," +
        //        "\"diagnosticsStorageAccountId\": { \"value\": \"Microsoft.Storage/storageAccounts/" + diagnosticsStorageAccountName + "\"}," +
        //        "\"diagnosticsStorageAccountType\": { \"value\": \"Standard_LRS\"}," +
        //        "\"addressPrefix\": { \"value\": \"10.17.3.0/24\"}," +
        //        "\"subnetName\": { \"value\": \"default\"}, \"subnetPrefix\": { \"value\": \"10.17.3.0/24\"}," +
        //        "\"publicIpAddressName\": { \"value\": \"" + virtualMachineName + "-ip\"}," +
        //        "\"publicIpAddressType\": { \"value\": \"Dynamic\"}" +
        //        "}";
        //    string templateString = File.ReadAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestData", "DeploymentTemplate.json"));

        //    DeploymentProperties deploymentProperties = new DeploymentProperties(DeploymentMode.Incremental)
        //    {
        //        Template = templateString,
        //        Parameters = deploymentParams
        //    };
        //    Deployment deploymentModel = new Deployment(deploymentProperties);

        //    Operation<DeploymentExtended> deploymentWait = await resourcesClient.Deployments.CreateOrUpdateAsync(resourceGroupName, deploymentName, deploymentModel);
        //    await deploymentWait.WaitForCompletionAsync();
        //}

        // TODO: we should decide after preview whehter we need to support compute resources like vmss in Network SDK
        //public async Task CreateVmss(ResourcesManagementClient resourcesClient, string resourceGroupName, string deploymentName)
        //{
        //    string templateString = File.ReadAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestData", "VmssDeploymentTemplate.json"));

        //    DeploymentProperties deploymentProperties = new DeploymentProperties(DeploymentMode.Incremental)
        //    {
        //        Template = templateString
        //    };
        //    Deployment deploymentModel = new Deployment(deploymentProperties);
        //    Operation<DeploymentExtended> deploymentWait = await resourcesClient.Deployments.CreateOrUpdateAsync(resourceGroupName, deploymentName, deploymentModel);
        //    await deploymentWait.WaitForCompletionAsync();
        //}

        public async Task <ExpressRouteCircuitResource> CreateDefaultExpressRouteCircuit(Resources.ResourceGroupResource resourceGroup, string circuitName, string location)
        {
            var sku = new ExpressRouteCircuitSku
            {
                Name   = "Premium_MeteredData",
                Tier   = "Premium",
                Family = "MeteredData"
            };

            var provider = new ExpressRouteCircuitServiceProviderProperties
            {
                BandwidthInMbps     = Convert.ToInt32(ExpressRouteTests.Circuit_BW),
                PeeringLocation     = ExpressRouteTests.Circuit_Location,
                ServiceProviderName = ExpressRouteTests.Circuit_Provider
            };

            var circuit = new ExpressRouteCircuitData()
            {
                Location = location,
                Tags     = { { "key", "value" } },
                Sku      = sku,
                ServiceProviderProperties = provider
            };

            // Put circuit
            var circuitCollection = resourceGroup.GetExpressRouteCircuits();
            Operation <ExpressRouteCircuitResource> circuitOperation = await circuitCollection.CreateOrUpdateAsync(WaitUntil.Completed, circuitName, circuit);

            Response <ExpressRouteCircuitResource> circuitResponse = await circuitOperation.WaitForCompletionAsync();

            Assert.AreEqual("Succeeded", circuitResponse.Value.Data.ProvisioningState.ToString());
            Response <ExpressRouteCircuitResource> getCircuitResponse = await circuitCollection.GetAsync(circuitName);

            return(getCircuitResponse);
        }