コード例 #1
0
        public async Task UpdateAvailabilitySet()
        {
            #region Snippet:Managing_Availability_Set_UpdateAnAvailabilitySet
            // First, initialize the ArmClient and get the default subscription
            ArmClient armClient = new ArmClient(new DefaultAzureCredential());
            // Now we get a ResourceGroup collection for that subscription
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            ResourceGroupCollection rgCollection = subscription.GetResourceGroups();

            // With the collection, we can create a new resource group with an specific name
            string        rgName        = "myRgName";
            ResourceGroup resourceGroup = await rgCollection.GetAsync(rgName);

            AvailabilitySetCollection availabilitySetCollection = resourceGroup.GetAvailabilitySets();
            string          availabilitySetName = "myAvailabilitySet";
            AvailabilitySet availabilitySet     = await availabilitySetCollection.GetAsync(availabilitySetName);

            // availabilitySet is an AvailabilitySet instance created above
            AvailabilitySetUpdate update = new AvailabilitySetUpdate()
            {
                PlatformFaultDomainCount = 3
            };
            AvailabilitySet updatedAvailabilitySet = await availabilitySet.UpdateAsync(update);

            #endregion Snippet:Managing_Availability_Set_UpdateAnAvailabilitySet
        }
コード例 #2
0
        public async Task GetIfExistsAvailabilitySet()
        {
            #region Snippet:Managing_Availability_Set_GetIfExistsForAvailabilitySet
            // First, initialize the ArmClient and get the default subscription
            ArmClient armClient = new ArmClient(new DefaultAzureCredential());
            // Now we get a ResourceGroup collection for that subscription
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            ResourceGroupCollection rgCollection = subscription.GetResourceGroups();

            string        rgName        = "myRgName";
            ResourceGroup resourceGroup = await rgCollection.GetAsync(rgName);

            AvailabilitySetCollection availabilitySetCollection = resourceGroup.GetAvailabilitySets();
            string          availabilitySetName = "myAvailabilitySet";
            AvailabilitySet availabilitySet     = await availabilitySetCollection.GetIfExistsAsync(availabilitySetName);

            if (availabilitySet == null)
            {
                Console.WriteLine($"Availability Set {availabilitySetName} does not exist.");
                return;
            }

            // At this point, we are sure that availabilitySet is a not null Availability Set, so we can use this object to perform any operations we want.

            #endregion Snippet:Managing_Availability_Set_GetIfExistsForAvailabilitySet
        }
コード例 #3
0
        public async Task CreateAvailabilitySet()
        {
            // First, initialize the ArmClient and get the default subscription
            ArmClient armClient = new ArmClient(new DefaultAzureCredential());
            // Now we get a ResourceGroup collection for that subscription
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            ResourceGroupCollection rgCollection = subscription.GetResourceGroups();

            // With the collection, we can create a new resource group with an specific name
            string        rgName   = "myRgName";
            AzureLocation location = AzureLocation.WestUS2;
            ResourceGroupCreateOrUpdateOperation rgLro = await rgCollection.CreateOrUpdateAsync(rgName, new ResourceGroupData(location));

            ResourceGroup resourceGroup = rgLro.Value;

            #region Snippet:Managing_Availability_Set_CreateAnAvailabilitySet
            AvailabilitySetCollection availabilitySetCollection = resourceGroup.GetAvailabilitySets();
            string availabilitySetName = "myAvailabilitySet";
            AvailabilitySetData input  = new AvailabilitySetData(location);
            AvailabilitySetCreateOrUpdateOperation lro = await availabilitySetCollection.CreateOrUpdateAsync(true, availabilitySetName, input);

            AvailabilitySet availabilitySet = lro.Value;
            #endregion Snippet:Managing_Availability_Set_CreateAnAvailabilitySet
        }
コード例 #4
0
        public async Task createStorageAccountAndGetBlobContainerCollection()
        {
            ArmClient            armClient    = new ArmClient(new DefaultAzureCredential());
            SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();

            string        rgName   = "myRgName";
            AzureLocation location = AzureLocation.WestUS2;
            ArmOperation <ResourceGroupResource> operation = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, new ResourceGroupData(location));

            ResourceGroupResource resourceGroup = operation.Value;

            this.resourceGroup = resourceGroup;
            StorageSku  sku         = new StorageSku(StorageSkuName.StandardGRS);
            StorageKind kind        = StorageKind.Storage;
            string      locationStr = "westus2";
            StorageAccountCreateParameters parameters        = new StorageAccountCreateParameters(sku, kind, locationStr);
            StorageAccountCollection       accountCollection = resourceGroup.GetStorageAccounts();
            string accountName = "myAccount";
            ArmOperation <StorageAccountResource> accountCreateOperation = await accountCollection.CreateOrUpdateAsync(WaitUntil.Started, accountName, parameters);

            storageAccount = await accountCreateOperation.WaitForCompletionAsync();

            #region Snippet:Managing_BlobContainers_GetBlobService
            BlobServiceResource blobService = storageAccount.GetBlobService();
            #endregion
            this.blobService = blobService;
        }
コード例 #5
0
        public async Task PuttingItAllTogether()
        {
            #region Snippet:Readme_PuttingItAllTogether
            // First we construct our client
            ArmClient client = new ArmClient(new DefaultAzureCredential());

            // Next we get a resource group object
            // ResourceGroup is a [Resource] object from above
            Subscription subscription = await client.GetDefaultSubscriptionAsync();
            ResourceGroupCollection resourceGroups = subscription.GetResourceGroups();
            ResourceGroup resourceGroup = await resourceGroups.GetAsync("myRgName");

            // Next we get the collection for the virtual machines
            // vmCollection is a [Resource]Collection object from above
            VirtualMachineCollection virtualMachines = resourceGroup.GetVirtualMachines();

            // Next we loop over all vms in the collection
            // Each vm is a [Resource] object from above
            await foreach (VirtualMachine virtualMachine in virtualMachines)
            {
                // We access the [Resource]Data properties from vm.Data
                if (!virtualMachine.Data.Tags.ContainsKey("owner"))
                {
                    // We can also access all operations from vm since it is already scoped for us
                    await virtualMachine.AddTagAsync("owner", "tagValue");
                }
            }
            #endregion Snippet:Readme_PuttingItAllTogether
        }
コード例 #6
0
        public async Task GettingResourceGroupCollection()
        {
            #region Snippet:Managing_Resource_Groups_GetResourceGroupCollection

            ArmClient    armClient    = new ArmClient(new DefaultAzureCredential());
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            ResourceGroupCollection rgCollection = subscription.GetResourceGroups();

            // code omitted for brevity

            string rgName = "myRgName";
#if !SNIPPET
            //Check if "myRgName" exists, if not, create it first or run CreateResourceGroup()
            ResourceGroup rg = await subscription.GetResourceGroups().GetIfExistsAsync(rgName);

            if (rg == null)
            {
                AzureLocation     location = AzureLocation.WestUS2;
                ResourceGroupData rgData   = new ResourceGroupData(location);
                _ = await rgCollection.CreateOrUpdateAsync(true, rgName, rgData);
            }
#endif
            ResourceGroup resourceGroup = await rgCollection.GetAsync(rgName);

            #endregion Snippet:Managing_Resource_Groups_GetResourceGroupCollection
        }
コード例 #7
0
        public async Task UpdateAResourceGroup()
        {
            #region Snippet:Managing_Resource_Groups_UpdateAResourceGroup
            // Note: Resource group named 'myRgName' should exist for this example to work.
            ArmClient    armClient    = new ArmClient(new DefaultAzureCredential());
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            string rgName = "myRgName";
#if !SNIPPET
            //Check if 'myRgName' exists, if not, create it first or run CreateResourceGroup()
            ResourceGroup rg = await subscription.GetResourceGroups().GetIfExistsAsync(rgName);

            if (rg == null)
            {
                AzureLocation           location     = AzureLocation.WestUS2;
                ResourceGroupCollection rgCollection = subscription.GetResourceGroups();
                ResourceGroupData       rgData       = new ResourceGroupData(location);
                _ = await rgCollection.CreateOrUpdateAsync(true, rgName, rgData);
            }
#endif
            ResourceGroup resourceGroup = await subscription.GetResourceGroups().GetAsync(rgName);

            resourceGroup = await resourceGroup.AddTagAsync("key", "value");

            #endregion Snippet:Managing_Resource_Groups_UpdateAResourceGroup
        }
コード例 #8
0
        protected async Task InitializeClients()
        {
            ArmClient    = GetArmClient();
            Subscription = await ArmClient.GetDefaultSubscriptionAsync();

            ResourceGroupsOperations = Subscription.GetResourceGroups();
        }
コード例 #9
0
        public async Task createStorageAccountAndGetFileShareCollection()
        {
            ArmClient    armClient    = new ArmClient(new DefaultAzureCredential());
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            string        rgName   = "myRgName";
            AzureLocation location = AzureLocation.WestUS2;
            ArmOperation <ResourceGroup> operation = await subscription.GetResourceGroups().CreateOrUpdateAsync(true, rgName, new ResourceGroupData(location));

            ResourceGroup resourceGroup = operation.Value;

            this.resourceGroup = resourceGroup;
            Sku    sku         = new Sku(SkuName.StandardGRS);
            Kind   kind        = Kind.Storage;
            string locationStr = "westus2";
            StorageAccountCreateParameters parameters        = new StorageAccountCreateParameters(sku, kind, locationStr);
            StorageAccountCollection       accountCollection = resourceGroup.GetStorageAccounts();
            string accountName = "myAccount";
            ArmOperation <StorageAccount> accountCreateOperation = await accountCollection.CreateOrUpdateAsync(false, accountName, parameters);

            storageAccount = await accountCreateOperation.WaitForCompletionAsync();

            #region Snippet:Managing_FileShares_GetFileService
            FileService fileService = await storageAccount.GetFileService().GetAsync();

            #endregion
            this.fileService = fileService;
        }
コード例 #10
0
        public async Task DeleteRecordSetPtr()
        {
            #region Snippet:Managing_RecordSetPtrs_DeleteRecordSetPtr
            ArmClient            armClient    = new ArmClient(new DefaultAzureCredential());
            SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();

            // first we need to get the resource group
            string rgName = "myRgName";
            ResourceGroupResource resourceGroup = await subscription.GetResourceGroups().GetAsync(rgName);

            // create a DnsZone
            string            dnsZoneName       = "sample.com";
            DnsZoneCollection dnsZoneCollection = resourceGroup.GetDnsZones();
            DnsZoneData       data = new DnsZoneData("Global")
            {
            };
            ArmOperation <DnsZoneResource> lro = await dnsZoneCollection.CreateOrUpdateAsync(WaitUntil.Completed, dnsZoneName, data);

            DnsZoneResource dnsZone = lro.Value;
            // Now we get the DnsZone collection from the resource group
            RecordSetPtrCollection recordSetPtrCollection = dnsZone.GetRecordSetPtrs();
            string recordSetPtrName           = "ptr";
            RecordSetPtrResource recordSetPtr = await recordSetPtrCollection.GetAsync(recordSetPtrName);

            await recordSetPtr.DeleteAsync(WaitUntil.Completed);

            #endregion Snippet:Managing_RecordSetPtrs_DeleteRecordSetPtr
        }
コード例 #11
0
        public async Task ListRecordSetPtrs()
        {
            #region Snippet:Managing_RecordSetPtrs_ListAllRecordSetPtrs
            ArmClient            armClient    = new ArmClient(new DefaultAzureCredential());
            SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();

            // first we need to get the resource group
            string rgName = "myRgName";
            ResourceGroupResource resourceGroup = await subscription.GetResourceGroups().GetAsync(rgName);

            // create a DnsZone
            string            dnsZoneName       = "sample.com";
            DnsZoneCollection dnsZoneCollection = resourceGroup.GetDnsZones();
            DnsZoneData       data = new DnsZoneData("Global")
            {
            };
            ArmOperation <DnsZoneResource> lro = await dnsZoneCollection.CreateOrUpdateAsync(WaitUntil.Completed, dnsZoneName, data);

            DnsZoneResource dnsZone = lro.Value;
            // With ListAsync(), we can get a list of the RecordSetPtrs
            RecordSetPtrCollection recordSetPtrCollection = dnsZone.GetRecordSetPtrs();
            AsyncPageable <RecordSetPtrResource> response = recordSetPtrCollection.GetAllAsync();
            await foreach (RecordSetPtrResource recordSetPtr in response)
            {
                Console.WriteLine(recordSetPtr.Data.Name);
            }
            #endregion Snippet:Managing_RecordSetPtrs_ListAllRecordSetPtrs
        }
コード例 #12
0
        public async Task CreateDisk()
        {
            #region Snippet:Managing_Disks_CreateADisk
            ArmClient    armClient    = new ArmClient(new DefaultAzureCredential());
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            // first we need to get the resource group
            string        rgName        = "myRgName";
            ResourceGroup resourceGroup = await subscription.GetResourceGroups().GetAsync(rgName);

            // Now we get the disk collection from the resource group
            DiskCollection diskCollection = resourceGroup.GetDisks();
            // Use the same location as the resource group
            string diskName = "myDisk";
            var    input    = new DiskData(resourceGroup.Data.Location)
            {
                Sku = new DiskSku()
                {
                    Name = DiskStorageAccountTypes.StandardLRS
                },
                CreationData = new CreationData(DiskCreateOption.Empty),
                DiskSizeGB   = 1,
            };
            ArmOperation <Disk> lro = await diskCollection.CreateOrUpdateAsync(true, diskName, input);

            Disk disk = lro.Value;
            #endregion Snippet:Managing_Disks_CreateADisk
        }
コード例 #13
0
        public override async Task SetUp()
        {
            if (Environment.Mode != RecordedTestMode.Playback)
            {
                _config = TestConfigurations.DefaultTargetManagedDisk;

                TokenCredential tokenCredentials = new Identity.ClientSecretCredential(
                    _config.ActiveDirectoryTenantId, _config.ActiveDirectoryApplicationId, _config.ActiveDirectoryApplicationSecret);

                ArmClient    client       = new ArmClient(tokenCredentials, _config.SubsriptionId);
                Subscription subscription = await client.GetDefaultSubscriptionAsync();

                _resourceGroup = await subscription.GetResourceGroups().GetAsync(_config.ResourceGroupName);

                var disks = await _resourceGroup.GetDisks().GetAllAsync().ToListAsync();

                var disk = disks.Where(d => d.Data.Name.Contains(_config.DiskNamePrefix)).First();

                Snapshot1 = await CreateSnapshot(disk, _config.DiskNamePrefix + Guid.NewGuid().ToString().Replace("-", ""));

                // The disk is attached to VM, wait some time to let OS background jobs write something to disk to create delta.
                await Task.Delay(TimeSpan.FromSeconds(60));

                Snapshot2 = await CreateSnapshot(disk, _config.DiskNamePrefix + Guid.NewGuid().ToString().Replace("-", ""));

                Snapshot1SASUri = await GrantAccess(Snapshot1);

                Snapshot2SASUri = await GrantAccess(Snapshot2);
            }

            Instance = this;
        }
コード例 #14
0
        public async Task AppConfigurationListKeyValues()
        {
            var          resourceGroupName = Recording.GenerateAssetName(ResourceGroupPrefix);
            Subscription sub = await ArmClient.GetDefaultSubscriptionAsync();

            ResourceGroup resourceGroup = await sub.GetResourceGroups().CreateOrUpdate(resourceGroupName, new Resources.ResourceGroupData(AzureLocation)).WaitForCompletionAsync();

            //create configuration
            var configurationStoreName      = Recording.GenerateAssetName("configuration");
            var configurationCreateResponse = await ConfigurationStoresOperations.StartCreateAsync(resourceGroupName, configurationStoreName,
                                                                                                   new ConfigurationStore("westus",
                                                                                                                          new Sku("Standard")
                                                                                                                          ));

            var configCreateResult = (await WaitForCompletionAsync(configurationCreateResponse)).Value;

            Assert.IsNotNull(configCreateResult);
            Assert.AreEqual(configCreateResult.ProvisioningState.ToString(), "Succeeded");
            //list configuration
            var configListResponse = ConfigurationStoresOperations.ListKeysAsync(resourceGroupName, configurationStoreName);
            var conListResult      = await configListResponse.ToEnumerableAsync();

            Assert.True(conListResult.Count >= 1);
            //# ConfigurationStoresListKeys[post]
            var configRegenerateResponse = await ConfigurationStoresOperations.RegenerateKeyAsync(resourceGroupName, configurationStoreName, new RegenerateKeyParameters()
            {
                Id = conListResult.First().Id
            });

            Assert.IsNotNull(configRegenerateResponse.Value);
            //TODO need to use data sdk to create key value
            //create Key-Value
            //var listKeyValueResponse = await ConfigurationStoresOperations.ListKeyValueAsync(resourceGroup, configurationStoreName,new ListKeyValueParameters(Key));
            //Assert.IsNotNull(listKeyValueResponse);
        }
コード例 #15
0
 public async Task ClearChallengeCacheforRecord()
 {
     if (Mode == RecordedTestMode.Record || Mode == RecordedTestMode.Playback)
     {
         Initialize();
     }
     _subscription = await ArmClient.GetDefaultSubscriptionAsync();
 }
コード例 #16
0
        public async Task SetUpWithDefaultSubscription()
        {
            #region Snippet:Managing_Resource_Groups_DefaultSubscription
            ArmClient    client       = new ArmClient(new DefaultAzureCredential());
            Subscription subscription = await client.GetDefaultSubscriptionAsync();

            #endregion Snippet:Managing_Resource_Groups_DefaultSubscription
        }
コード例 #17
0
        public async Task RestorableDatabaseAccountListByLocation()
        {
            _restorableDatabaseAccount = await CreateRestorableDatabaseAccount(Recording.GenerateAssetName("r-database-account-"));

            var restorableAccounts = await(await ArmClient.GetDefaultSubscriptionAsync()).GetRestorableDatabaseAccounts(AzureLocation.WestUS).GetAllAsync().ToEnumerableAsync();

            Assert.That(restorableAccounts.Any(account => account.Data.AccountName == _restorableDatabaseAccount.Data.Name));
        }
コード例 #18
0
 public async Task TestSetUp()
 {
     if (Mode == RecordedTestMode.Record || Mode == RecordedTestMode.Playback)
     {
         Initialize();
         string groupName = Recording.GenerateAssetName(ResourceGroupPrefix);
         ResGroup = await(await ArmClient.GetDefaultSubscriptionAsync().Result.GetResourceGroups().CreateOrUpdateAsync(groupName, new ResourceGroupData(Location))).WaitForCompletionAsync();
     }
 }
コード例 #19
0
        public async Task GettingDefaultSubscription()
        {
            #region Snippet:Hello_World_Async_DefaultSubscription
            ArmClient            client       = new ArmClient(new DefaultAzureCredential());
            SubscriptionResource subscription = await client.GetDefaultSubscriptionAsync();

            Console.WriteLine(subscription.Id);
            #endregion Snippet:Hello_World_Async_DefaultSubscription
        }
コード例 #20
0
        public async Task CheckDnsAvailabilityTest()
        {
            var subscription = await ArmClient.GetDefaultSubscriptionAsync();

            string domainNameLabel = Recording.GenerateAssetName("domainnamelabel");
            Response <Models.DnsNameAvailabilityResult> dnsNameAvailability = await subscription.CheckDnsNameAvailabilityAsync(TestEnvironment.Location, domainNameLabel);

            Assert.True(dnsNameAvailability.Value.Available);
        }
コード例 #21
0
        public async Task BGPCommunityApiTest()
        {
            Subscription subscription = await ArmClient.GetDefaultSubscriptionAsync();

            AsyncPageable <BgpServiceCommunity> communitiesAsync = subscription.GetBgpServiceCommunitiesAsync();
            List <BgpServiceCommunity>          communities      = await communitiesAsync.ToEnumerableAsync();

            Assert.IsNotEmpty(communities);
            Assert.That(communities.Any(c => c.BgpCommunities.Any(b => b.IsAuthorizedToUse.HasValue ? b.IsAuthorizedToUse.Value : false)));
        }
コード例 #22
0
        public async Task ClearChallengeCacheforRecord()
        {
            if (Mode == RecordedTestMode.Record || Mode == RecordedTestMode.Playback)
            {
                Initialize();
            }
            _subscription = await ArmClient.GetDefaultSubscriptionAsync();

            resourceGroup = await CreateResourceGroup(Recording.GenerateAssetName(NamePrefix));
        }
コード例 #23
0
        public async Task GettingSpecifiedDefaultSubscriptionAsync()
        {
            #region Snippet:Hello_World_Async_SpecifyDefaultSubscription
            string               defaultSubscriptionId = "your-subscription-id";
            ArmClient            client       = new ArmClient(new DefaultAzureCredential(), defaultSubscriptionId);
            SubscriptionResource subscription = await client.GetDefaultSubscriptionAsync();

            Console.WriteLine(subscription.Id);
            #endregion
        }
        public async Task TestSetUp()
        {
            if (Mode == RecordedTestMode.Record || Mode == RecordedTestMode.Playback)
            {
                Initialize();
                string groupName    = Recording.GenerateAssetName(ResourceGroupPrefix);
                string VnetName     = Recording.GenerateAssetName("vnetname");
                string SubnetName   = Recording.GenerateAssetName("subnetname");
                string EndpointName = Recording.GenerateAssetName("endpointxyz");
                ResGroup = await(await ArmClient.GetDefaultSubscriptionAsync().Result.GetResourceGroups().CreateOrUpdateAsync(groupName, new ResourceGroupData(Location))).WaitForCompletionAsync();
                string configurationStoreName = Recording.GenerateAssetName("testapp-");
                ConfigurationStoreData configurationStoreData = new ConfigurationStoreData(Location, new Models.Sku("Standard"))
                {
                    PublicNetworkAccess = PublicNetworkAccess.Disabled
                };
                ConfigStore = await(await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(configurationStoreName, configurationStoreData)).WaitForCompletionAsync();
                // Prepare VNet and Private Endpoint
                VirtualNetworkData vnetData = new VirtualNetworkData()
                {
                    Location     = "eastus",
                    AddressSpace = new AddressSpace()
                    {
                        AddressPrefixes = { "10.0.0.0/16", }
                    },
                    DhcpOptions = new DhcpOptions()
                    {
                        DnsServers = { "10.1.1.1", "10.1.2.4" }
                    },
                    Subnets = { new SubnetData()
                                {
                                    Name = SubnetName, AddressPrefix = "10.0.0.0/24", PrivateEndpointNetworkPolicies = "Disabled"
                                } }
                };
                VirtualNetwork      vnet = await(await ResGroup.GetVirtualNetworks().CreateOrUpdateAsync(VnetName, vnetData)).WaitForCompletionAsync();
                PrivateEndpointData privateEndpointData = new PrivateEndpointData()
                {
                    Location = "eastus",
                    PrivateLinkServiceConnections = { new PrivateLinkServiceConnection()
                                                      {
                                                          Name = "myconnection",
                                                          PrivateLinkServiceId = ConfigStore.Data.Id,
                                                          GroupIds             = { "configurationStores" },
                                                          RequestMessage       = "Please approve my connection",
                                                      } },
                    Subnet = new SubnetData()
                    {
                        Id = "/subscriptions/" + TestEnvironment.SubscriptionId + "/resourceGroups/" + groupName + "/providers/Microsoft.Network/virtualNetworks/" + VnetName + "/subnets/" + SubnetName
                    }
                };
                PrivateEndpoint = await(await ResGroup.GetPrivateEndpoints().CreateOrUpdateAsync(EndpointName, privateEndpointData)).WaitForCompletionAsync();
                List <PrivateEndpointConnection> connections = await ConfigStore.GetPrivateEndpointConnections().GetAllAsync().ToEnumerableAsync();

                Connection = connections.FirstOrDefault();
            }
        }
コード例 #25
0
        public async Task SetUp()
        {
            _rgName = Recording.GenerateAssetName("CoreRg");
            _client = GetArmClient();
            var subscription = await _client.GetDefaultSubscriptionAsync().ConfigureAwait(false);

            _collection = subscription.GetResourceGroups();
            var rgOp = await _collection.Construct(AzureLocation.WestUS2).CreateOrUpdateAsync(_rgName);

            _resourceGroup = rgOp.Value;
        }
コード例 #26
0
        public async Task BGPCommunityApiTest()
        {
            //_ = NetworkManagementTestUtilities.GetResourceLocation(ArmClient, "Microsoft.Network/routefilters");
            Subscription subscription = await ArmClient.GetDefaultSubscriptionAsync();

            AsyncPageable <BgpServiceCommunity> communitiesAsync = subscription.GetBgpServiceCommunitiesAsync();
            List <BgpServiceCommunity>          communities      = await communitiesAsync.ToEnumerableAsync();

            Assert.IsNotEmpty(communities);
            Assert.True(communities.First().BgpCommunities.First().IsAuthorizedToUse);
        }
コード例 #27
0
        protected async Task initialize()
        {
            ArmClient    armClient    = new ArmClient(new DefaultAzureCredential());
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            ResourceGroupCollection rgCollection = subscription.GetResourceGroups();
            // With the collection, we can create a new resource group with an specific name
            string   rgName   = "myRgName";
            Location location = Location.WestUS2;

            resourceGroup = await rgCollection.CreateOrUpdate(rgName, new ResourceGroupData(location)).WaitForCompletionAsync();
        }
コード例 #28
0
        public async Task ValidateHttpPipelines()
        {
            SubscriptionResource subscription = await _client.GetDefaultSubscriptionAsync().ConfigureAwait(false);

            await subscription.GetResourceGroups().Construct(AzureLocation.WestUS)
            .CreateOrUpdateAsync(_rgName);

            await foreach (var rg in subscription.GetResourceGroups().GetAllAsync())
            {
                Assert.AreEqual(rg.Pipeline.GetHashCode(), subscription.Pipeline.GetHashCode());
            }
        }
コード例 #29
0
 public async Task CreateResourceGroup()
 {
     #region Snippet:Readme_GetResourceGroupCollection
     ArmClient armClient = new ArmClient(new DefaultAzureCredential());
     SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();
     ResourceGroupCollection rgCollection = subscription.GetResourceGroups();
     // With the collection, we can create a new resource group with an specific name
     string rgName = "myRgName";
     AzureLocation location = AzureLocation.WestUS2;
     ArmOperation<ResourceGroupResource> lro = await rgCollection.CreateOrUpdateAsync(WaitUntil.Completed, rgName, new ResourceGroupData(location));
     ResourceGroupResource resourceGroup = lro.Value;
     #endregion
 }
コード例 #30
0
        public async Task DatabaseAccountListBySubscriptionTest()
        {
            var account = await CreateDatabaseAccount(Recording.GenerateAssetName("dbaccount-"), DatabaseAccountKind.MongoDB);

            var accounts = await(await ArmClient.GetDefaultSubscriptionAsync()).GetDatabaseAccountsAsync().ToEnumerableAsync();

            Assert.IsNotNull(accounts);

            var accountInList = accounts.Single(account => account.Data.Name == _databaseAccountName);

            Assert.IsNotNull(accountInList);
            VerifyCosmosDBAccount(account, accountInList);
        }