public async Task GetAll()
        {
            var container = await GetDiskContainerAsync();

            var input = ResourceDataHelper.GetEmptyDiskData(DefaultLocation, new Dictionary <string, string>()
            {
                { "key", "value" }
            });

            _ = await container.CreateOrUpdateAsync(Recording.GenerateAssetName("testDisk-"), input);

            _ = await container.CreateOrUpdateAsync(Recording.GenerateAssetName("testDisk-"), input);

            int count = 0;

            await foreach (var disk in container.GetAllAsync())
            {
                count++;
            }
            Assert.GreaterOrEqual(count, 2);
        }
예제 #2
0
        public async Task GetAll()
        {
            var collection = await GetGalleryCollectionAsync();

            var name1  = Recording.GenerateAssetName("testGallery_");
            var name2  = Recording.GenerateAssetName("testGallery_");
            var input1 = ResourceDataHelper.GetBasicGalleryData(DefaultLocation);
            var input2 = ResourceDataHelper.GetBasicGalleryData(DefaultLocation);

            _ = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name1, input1);

            _ = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name2, input2);

            int count = 0;

            await foreach (var gallery in collection.GetAllAsync())
            {
                count++;
            }
            Assert.GreaterOrEqual(count, 2);
        }
예제 #3
0
        public async Task Update()
        {
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-");

            string          afdProfileName = Recording.GenerateAssetName("AFDProfile-");
            ProfileResource afdProfile     = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor);

            string afdEndpointName = Recording.GenerateAssetName("AFDEndpoint-");
            AfdEndpointResource afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName);

            PatchableAfdEndpointData updateOptions = new PatchableAfdEndpointData();

            updateOptions.Tags.Add("newTag", "newValue");
            var lro = await afdEndpointInstance.UpdateAsync(WaitUntil.Completed, updateOptions);

            AfdEndpointResource updatedAfdEndpointInstance = lro.Value;

            ResourceDataHelper.AssertAfdEndpointUpdate(updatedAfdEndpointInstance, updateOptions);
        }
예제 #4
0
        public async Task Update()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await subscription.GetResourceGroups().GetAsync("DeviceUpdateResourceGroup");

            DeviceUpdateAccount account = await rg.GetDeviceUpdateAccounts().GetAsync("AzureDeviceUpdateAccount");

            DeviceUpdateInstance instance = await account.GetDeviceUpdateInstances().GetAsync("Instance");

            TagUpdateOptions updateOptions = new TagUpdateOptions();

            updateOptions.Tags.Add("newTag", "newValue");
            DeviceUpdateInstance updatedInstance = await instance.UpdateAsync(updateOptions);

            ResourceDataHelper.AssertInstanceUpdate(updatedInstance, updateOptions);
            updateOptions.Tags.Clear();
            updatedInstance = await instance.UpdateAsync(updateOptions);

            ResourceDataHelper.AssertInstanceUpdate(updatedInstance, updateOptions);
        }
예제 #5
0
        public Bundle ResourceTypeHistory(string resourceType, HistoryParameters parameters = null)
        {
            if (parameters == null)
            {
                parameters = HistoryParameters.Empty;
            }

            var request = new HistoryRequest()
            {
                ResourceType = resourceType,
                Query        = parameters.ToString()
            };

            var historyResponse = _context.Call(FhirSchema.Name, FhirSchema.Func.TypeHistory)
                                  .WithJson(request.ToJson())
                                  .Cast <String>();

            var resultBundle = ResourceDataHelper.JsonToBundle(historyResponse);

            return(resultBundle);
        }
        public async Task GetAll()
        {
            var container = await GetCollectionAsync();

            var grafanaName1 = Recording.GenerateAssetName("sdkTestGrafana1");
            var grafanaName2 = Recording.GenerateAssetName("sdkTestGrafana2");
            var input1       = ResourceDataHelper.GetGrafanaResourceData(DefaultLocation);
            var input2       = ResourceDataHelper.GetGrafanaResourceData(DefaultLocation);

            _ = await container.CreateOrUpdateAsync(WaitUntil.Completed, grafanaName1, input1);

            _ = await container.CreateOrUpdateAsync(WaitUntil.Completed, grafanaName2, input2);

            int count = 0;

            await foreach (var appServicePlan in container.GetAllAsync())
            {
                count++;
            }
            Assert.GreaterOrEqual(count, 2);
        }
        public async Task GetAll()
        {
            var collection = await GetAvailabilitySetCollectionAsync();

            var input = ResourceDataHelper.GetBasicAvailabilitySetData(DefaultLocation);

            input.Tags.ReplaceWith(new Dictionary <string, string>
            {
                { "key", "value" }
            });
            _ = await collection.CreateOrUpdateAsync(WaitUntil.Completed, Recording.GenerateAssetName("testAS-"), input);

            _ = await collection.CreateOrUpdateAsync(WaitUntil.Completed, Recording.GenerateAssetName("testAs-"), input);

            int count = 0;

            await foreach (var availabilitySet in collection.GetAllAsync())
            {
                count++;
            }
            Assert.GreaterOrEqual(count, 2);
        }
        public async Task UpdateVmIdentityToRemoveUser()
        {
            var collection = await GetVirtualMachineCollectionAsync();

            var vmName = Recording.GenerateAssetName("testVM-");
            var nic    = await CreateBasicDependenciesOfVirtualMachineAsync();

            var input = ResourceDataHelper.GetBasicLinuxVirtualMachineData(DefaultLocation, vmName, nic.Id);

            input.Identity = new ManagedServiceIdentity(ManagedServiceIdentityType.UserAssigned);
            var userAssignedIdentity = await CreateUserAssignedIdentityAsync();

            input.Identity.UserAssignedIdentities.Add(userAssignedIdentity.Id.ToString(), new UserAssignedIdentity());
            var lro = await collection.CreateOrUpdateAsync(true, vmName, input);

            VirtualMachine virtualMachine = lro.Value;

            Assert.AreEqual(vmName, virtualMachine.Data.Name);
            Assert.AreEqual(ManagedServiceIdentityType.UserAssigned, virtualMachine.Data.Identity.Type);
            Assert.AreEqual(virtualMachine.Data.Identity.UserAssignedIdentities.Count, 1);
            Assert.Null(virtualMachine.Data.Identity.PrincipalId);
            Assert.NotNull(virtualMachine.Data.Identity.UserAssignedIdentities[userAssignedIdentity.Id.ToString()].PrincipalId);

            // With JSON Merge Patch, we only need to put the identity to add in the dictionary for update operation.
            var identity = new ManagedServiceIdentity(ManagedServiceIdentityType.None);

            identity.UserAssignedIdentities.Add(userAssignedIdentity.Id.ToString(), null);
            var updateOptions = new VirtualMachineUpdateOptions()
            {
                Identity = identity
            };

            lro = await virtualMachine.UpdateAsync(true, updateOptions);

            VirtualMachine updatedVM = lro.Value;

            Assert.Null(updatedVM.Data.Identity);
        }
        public async Task UpdateVmIdentityFromSystemToSystemUser()
        {
            var collection = await GetVirtualMachineCollectionAsync();

            var vmName = Recording.GenerateAssetName("testVM-");
            var nic    = await CreateBasicDependenciesOfVirtualMachineAsync();

            var input = ResourceDataHelper.GetBasicLinuxVirtualMachineData(DefaultLocation, vmName, nic.Id);

            input.Identity = new ManagedServiceIdentity(ManagedServiceIdentityType.SystemAssigned);
            var lro = await collection.CreateOrUpdateAsync(true, vmName, input);

            VirtualMachine virtualMachine = lro.Value;

            Assert.AreEqual(vmName, virtualMachine.Data.Name);
            Assert.AreEqual(ManagedServiceIdentityType.SystemAssigned, virtualMachine.Data.Identity.Type);
            Assert.IsEmpty(virtualMachine.Data.Identity.UserAssignedIdentities);
            Assert.NotNull(virtualMachine.Data.Identity.PrincipalId);
            Assert.NotNull(virtualMachine.Data.Identity.TenantId);

            var identity             = new ManagedServiceIdentity(ManagedServiceIdentityType.SystemAssignedUserAssigned);
            var userAssignedIdentity = await CreateUserAssignedIdentityAsync();

            identity.UserAssignedIdentities.Add(userAssignedIdentity.Id.ToString(), new UserAssignedIdentity());
            var updateOptions = new VirtualMachineUpdateOptions()
            {
                Identity = identity
            };

            lro = await virtualMachine.UpdateAsync(true, updateOptions);

            VirtualMachine updatedVM = lro.Value;

            Assert.AreEqual(ManagedServiceIdentityType.SystemAssignedUserAssigned, updatedVM.Data.Identity.Type);
            Assert.AreEqual(updatedVM.Data.Identity.UserAssignedIdentities.Count, 1);
            Assert.NotNull(updatedVM.Data.Identity.PrincipalId);
            Assert.NotNull(updatedVM.Data.Identity.UserAssignedIdentities[userAssignedIdentity.Id.ToString()].PrincipalId);
        }
예제 #10
0
        public async Task CreateVmWithSystemAndUserAssignedIdentity()
        {
            var collection = await GetVirtualMachineCollectionAsync();

            var vmName = Recording.GenerateAssetName("testVM-");
            var nic    = await CreateBasicDependenciesOfVirtualMachineAsync();

            var input = ResourceDataHelper.GetBasicLinuxVirtualMachineData(DefaultLocation, vmName, nic.Id);

            input.Identity = new ManagedServiceIdentity(ManagedServiceIdentityType.SystemAssignedUserAssigned);
            var userAssignedIdentity = await CreateUserAssignedIdentityAsync();

            input.Identity.UserAssignedIdentities.Add(userAssignedIdentity.Id, new UserAssignedIdentity());
            var lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, input);

            VirtualMachineResource virtualMachine = lro.Value;

            Assert.AreEqual(vmName, virtualMachine.Data.Name);
            Assert.AreEqual(ManagedServiceIdentityType.SystemAssignedUserAssigned, virtualMachine.Data.Identity.ManagedServiceIdentityType);
            Assert.AreEqual(virtualMachine.Data.Identity.UserAssignedIdentities.Count, 1);
            Assert.NotNull(virtualMachine.Data.Identity.PrincipalId);
            Assert.NotNull(virtualMachine.Data.Identity.UserAssignedIdentities[userAssignedIdentity.Id].PrincipalId);
        }
        public async Task Update()
        {
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-");

            string          cdnProfileName = Recording.GenerateAssetName("profile-");
            ProfileResource cdnProfile     = await CreateCdnProfile(rg, cdnProfileName, CdnSkuName.StandardMicrosoft);

            string cdnEndpointName          = Recording.GenerateAssetName("endpoint-");
            CdnEndpointResource cdnEndpoint = await CreateCdnEndpoint(cdnProfile, cdnEndpointName);

            PatchableCdnEndpointData updateOptions = new PatchableCdnEndpointData
            {
                IsHttpAllowed    = false,
                OriginPath       = "/path/valid",
                OriginHostHeader = "www.bing.com"
            };
            var lro = await cdnEndpoint.UpdateAsync(WaitUntil.Completed, updateOptions);

            CdnEndpointResource updatedCdnEndpoint = lro.Value;

            ResourceDataHelper.AssertEndpointUpdate(updatedCdnEndpoint, updateOptions);
        }
예제 #12
0
        public async Task Update()
        {
            //This test doesn't create a new afd custom domain bucause the update actoin needs to manualy add dns txt record and validate.
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await subscription.GetResourceGroups().GetAsync("CdnTest");

            Profile afdProfile = await rg.GetProfiles().GetAsync("testAFDProfile");

            AfdCustomDomain afdCustomDomain = await afdProfile.GetAfdCustomDomains().GetAsync("customdomain4afd-azuretest-net");

            AfdCustomDomainUpdateOptions updateOptions = new AfdCustomDomainUpdateOptions
            {
                TlsSettings = new AfdCustomDomainHttpsParameters(AfdCertificateType.ManagedCertificate)
                {
                    MinimumTlsVersion = AfdMinimumTlsVersion.TLS12
                },
            };
            var lro = await afdCustomDomain.UpdateAsync(true, updateOptions);

            AfdCustomDomain updatedAfdCustomDomain = lro.Value;

            ResourceDataHelper.AssertAfdDomainUpdate(updatedAfdCustomDomain, updateOptions);
        }
        public async Task Update()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-");

            string  afdProfileName = Recording.GenerateAssetName("AFDProfile-");
            Profile afdProfile     = await CreateAfdProfile(rg, afdProfileName, SkuName.StandardAzureFrontDoor);

            string      afdEndpointName     = Recording.GenerateAssetName("AFDEndpoint-");
            AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName);

            AfdEndpointUpdateOptions updateOptions = new AfdEndpointUpdateOptions
            {
                OriginResponseTimeoutSeconds = 30
            };

            updateOptions.Tags.Add("newTag", "newValue");
            var lro = await afdEndpointInstance.UpdateAsync(updateOptions);

            AfdEndpoint updatedAfdEndpointInstance = lro.Value;

            ResourceDataHelper.AssertAfdEndpointUpdate(updatedAfdEndpointInstance, updateOptions);
        }