public async Task Update() { var vmssName = Recording.GenerateAssetName("testVMSS-"); var vmss = await CreateVirtualMachineScaleSetAsync(vmssName); // Create a PPG here and add this PPG to this virtual machine using Update var ppgName = Recording.GenerateAssetName("testPPG-"); var ppgData = new ProximityPlacementGroupData(DefaultLocation) { }; var ppgLro = await _resourceGroup.GetProximityPlacementGroups().CreateOrUpdateAsync(true, ppgName, ppgData); ProximityPlacementGroup ppg = ppgLro.Value; // update PPG requires the VM to be deallocated await vmss.DeallocateAsync(true); var update = new VirtualMachineScaleSetUpdateOptions() { ProximityPlacementGroup = new WritableSubResource() { Id = ppg.Id } }; var lro = await vmss.UpdateAsync(true, update); VirtualMachineScaleSet updatedVM = lro.Value; Assert.AreEqual(ppg.Id, updatedVM.Data.ProximityPlacementGroup.Id); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ExecuteClientAction(() => { if (ShouldProcess(this.Name, VerbsCommon.New)) { string resourceGroupName = this.ResourceGroupName; string proximityPlacementGroupName = this.Name; ProximityPlacementGroup parameters = new ProximityPlacementGroup(); if (this.ProximityPlacementGroupType != null) { parameters.ProximityPlacementGroupType = this.ProximityPlacementGroupType; } parameters.Location = this.Location; parameters.Tags = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null; var result = ProximityPlacementGroupsClient.CreateOrUpdate(resourceGroupName, proximityPlacementGroupName, parameters); var psObject = new PSProximityPlacementGroup(); ComputeAutomationAutoMapperProfile.Mapper.Map <ProximityPlacementGroup, PSProximityPlacementGroup>(result, psObject); WriteObject(psObject); } }); }
public async Task <Response <ProximityPlacementGroup> > CreateOrUpdateAsync(string resourceGroupName, string proximityPlacementGroupName, ProximityPlacementGroup parameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (proximityPlacementGroupName == null) { throw new ArgumentNullException(nameof(proximityPlacementGroupName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var message = CreateCreateOrUpdateRequest(resourceGroupName, proximityPlacementGroupName, parameters); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: case 201: { ProximityPlacementGroup value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = ProximityPlacementGroup.DeserializeProximityPlacementGroup(document.RootElement); return(Response.FromValue(value, message.Response)); }
private void VerifyPutPatchGetAndDeleteOperations_Scenarios(ProximityPlacementGroup inputProximityPlacementGroup, ProximityPlacementGroup expectedProximityPlacementGroup) { var proximityPlacementGroupName = ComputeManagementTestUtilities.GenerateName("testppg"); // Create and expect success. ProximityPlacementGroup outProximityPlacementGroup = m_CrpClient.ProximityPlacementGroups.CreateOrUpdate(m_resourceGroup1Name, proximityPlacementGroupName, inputProximityPlacementGroup); ValidateProximityPlacementGroup(expectedProximityPlacementGroup, outProximityPlacementGroup, proximityPlacementGroupName); // Update and expect success. inputProximityPlacementGroup.Tags.Add("UpdateTag1", "updateValue1"); outProximityPlacementGroup = m_CrpClient.ProximityPlacementGroups.CreateOrUpdate(m_resourceGroup1Name, proximityPlacementGroupName, inputProximityPlacementGroup); ValidateProximityPlacementGroup(expectedProximityPlacementGroup, outProximityPlacementGroup, proximityPlacementGroupName); // Get and expect success. outProximityPlacementGroup = m_CrpClient.ProximityPlacementGroups.Get(m_resourceGroup1Name, proximityPlacementGroupName); ValidateProximityPlacementGroup(expectedProximityPlacementGroup, outProximityPlacementGroup, proximityPlacementGroupName); // Put and expect failure try { //Updating ProximityPlacementGroupType in inputProximityPlacementGroup for a Update call. if (expectedProximityPlacementGroup.ProximityPlacementGroupType == ProximityPlacementGroupType.Standard) { inputProximityPlacementGroup.ProximityPlacementGroupType = ProximityPlacementGroupType.Ultra; } else { inputProximityPlacementGroup.ProximityPlacementGroupType = ProximityPlacementGroupType.Standard; } outProximityPlacementGroup = null; outProximityPlacementGroup = m_CrpClient.ProximityPlacementGroups.CreateOrUpdate(m_resourceGroup1Name, proximityPlacementGroupName, inputProximityPlacementGroup); } catch (CloudException ex) { Assert.True(ex.Response.StatusCode == HttpStatusCode.Conflict, $"Expecting HttpStatusCode {HttpStatusCode.Conflict}, while actual HttpStatusCode is {ex.Response.StatusCode}."); Assert.Equal("Changing property 'proximityPlacementGroup.properties.proximityPlacementGroupType' is not allowed.", ex.Message, StringComparer.OrdinalIgnoreCase); } Assert.True(outProximityPlacementGroup == null, "ProximityPlacementGroup in response should be null."); //Patch and expect success ProximityPlacementGroupUpdate proximityPlacementGroupUpdate = new ProximityPlacementGroupUpdate() { Tags = inputProximityPlacementGroup.Tags }; //Note: Same Tags object is referred in proximityPlacementGroupUpdate and expectedProximityPlacementGroup, //hence this will also update tags in expectedProximityPlacementGroup. proximityPlacementGroupUpdate.Tags.Add("UpdateTag2", "updateValue2"); outProximityPlacementGroup = m_CrpClient.ProximityPlacementGroups.Update(m_resourceGroup1Name, proximityPlacementGroupName, proximityPlacementGroupUpdate.Tags); ValidateProximityPlacementGroup(expectedProximityPlacementGroup, outProximityPlacementGroup, proximityPlacementGroupName); // Clean up m_CrpClient.ProximityPlacementGroups.Delete(m_resourceGroup1Name, proximityPlacementGroupName); }
public async Task PlacementGroupId() { var asetName = Recording.GenerateAssetName("aset-"); AvailabilitySet aset = await CreateAvailabilitySetAsync(asetName); var beforeAdd = aset.Data.ProximityPlacementGroupId; ResourceGroup rg = Client.GetResourceGroup(ResourceGroup.CreateResourceIdentifier(aset.Id.SubscriptionId, aset.Id.ResourceGroupName)); var proxGrpName = Recording.GenerateAssetName("proxGrp-"); ProximityPlacementGroup proxGrp = (await rg.GetProximityPlacementGroups().CreateOrUpdateAsync(true, proxGrpName, new ProximityPlacementGroupData(DefaultLocation))).Value; AvailabilitySetUpdateOptions updateOptions = new AvailabilitySetUpdateOptions(); updateOptions.ProximityPlacementGroupId = proxGrp.Id; aset = await aset.UpdateAsync(updateOptions); var addIdResult = aset.Data.ProximityPlacementGroupId; updateOptions.ProximityPlacementGroupId = null; aset = await aset.UpdateAsync(updateOptions); var removeIdResult = aset.Data.ProximityPlacementGroupId; var asetName2 = Recording.GenerateAssetName("aset-"); AvailabilitySet aset2 = await CreateAvailabilitySetAsync(asetName2); var newBeforeAdd = aset2.Data.ProximityPlacementGroup?.Id; AvailabilitySetUpdateOptions updateOptions2 = new AvailabilitySetUpdateOptions(); updateOptions2.ProximityPlacementGroup = new Resources.Models.WritableSubResource(); updateOptions2.ProximityPlacementGroup.Id = proxGrp.Id; aset2 = await aset2.UpdateAsync(updateOptions2); var newAddIdResult = aset2.Data.ProximityPlacementGroup.Id; updateOptions2.ProximityPlacementGroup.Id = null; aset2 = await aset2.UpdateAsync(updateOptions2); var newRemoveIdResult = aset2.Data.ProximityPlacementGroup?.Id; updateOptions2.ProximityPlacementGroup.Id = proxGrp.Id; aset2 = await aset2.UpdateAsync(updateOptions2); Assert.NotNull(aset2.Data.ProximityPlacementGroup.Id); updateOptions2.ProximityPlacementGroup = null; aset2 = await aset2.UpdateAsync(updateOptions2); var newRemoveOuterIdResult = aset2.Data.ProximityPlacementGroup?.Id; Assert.AreEqual(beforeAdd, newBeforeAdd); Assert.AreEqual(addIdResult, newAddIdResult); Assert.AreEqual(removeIdResult, newRemoveIdResult); Assert.AreEqual(removeIdResult, newRemoveOuterIdResult); }
private async Task VerifyPutPatchGetAndDeleteWithInvalidValues_Failure() { var ProximityPlacementGroupName = Recording.GenerateAssetName("testppg"); var inputProximityPlacementGroup = new ProximityPlacementGroup("") { Tags = { { "RG", "rg" }, { "testTag", "1" }, }, }; // Put and expect failure ProximityPlacementGroup expectedProximityPlacementGroup = null; async void CreateAndExpectFailure() { try { // Create and expect success. expectedProximityPlacementGroup = await ProximityPlacementGroupsOperations.CreateOrUpdateAsync( m_resourceGroup1Name, ProximityPlacementGroupName, inputProximityPlacementGroup); } catch (Exception ex) { Assert.NotNull(ex); //Assert.True(ex.Response.StatusCode == HttpStatusCode.BadRequest, $"Expecting HttpStatusCode {HttpStatusCode.BadRequest}, while actual HttpStatusCode is {ex.Response.StatusCode}."); } Assert.True(expectedProximityPlacementGroup == null); } //Verify failure when location is invalid CreateAndExpectFailure(); //Verify failure when ProximityPlacementGroupType is invalid inputProximityPlacementGroup.Location = m_location; inputProximityPlacementGroup.ProximityPlacementGroupType = "Invalid"; CreateAndExpectFailure(); //Verify success when ProximityPlacementGroup is valid inputProximityPlacementGroup.ProximityPlacementGroupType = ProximityPlacementGroupType.Standard; expectedProximityPlacementGroup = await ProximityPlacementGroupsOperations.CreateOrUpdateAsync( m_resourceGroup1Name, ProximityPlacementGroupName, inputProximityPlacementGroup); ValidateProximityPlacementGroup(inputProximityPlacementGroup, expectedProximityPlacementGroup, ProximityPlacementGroupName); // Get and expect success. expectedProximityPlacementGroup = await ProximityPlacementGroupsOperations.GetAsync(m_resourceGroup1Name, ProximityPlacementGroupName); ValidateProximityPlacementGroup(inputProximityPlacementGroup, expectedProximityPlacementGroup, ProximityPlacementGroupName); // Clean up await ProximityPlacementGroupsOperations.DeleteAsync(m_resourceGroup1Name, ProximityPlacementGroupName); }
private void VerifyPutPatchGetAndDeleteWithInvalidValues_Failure() { var ProximityPlacementGroupName = ComputeManagementTestUtilities.GenerateName("testppg"); var inputProximityPlacementGroup = new ProximityPlacementGroup { Location = "", Tags = new Dictionary <string, string>() { { "RG", "rg" }, { "testTag", "1" }, }, }; // Put and expect failure ProximityPlacementGroup expectedProximityPlacementGroup = null; void CreateAndExpectFailure() { try { // Create and expect success. expectedProximityPlacementGroup = m_CrpClient.ProximityPlacementGroups.CreateOrUpdate( m_resourceGroup1Name, ProximityPlacementGroupName, inputProximityPlacementGroup); } catch (CloudException ex) { Assert.True(ex.Response.StatusCode == HttpStatusCode.BadRequest, $"Expecting HttpStatusCode {HttpStatusCode.BadRequest}, while actual HttpStatusCode is {ex.Response.StatusCode}."); } Assert.True(expectedProximityPlacementGroup == null); } //Verify failure when location is invalid CreateAndExpectFailure(); //Verify failure when ProximityPlacementGroupType is invalid inputProximityPlacementGroup.Location = m_location; inputProximityPlacementGroup.ProximityPlacementGroupType = "Invalid"; CreateAndExpectFailure(); //Verify success when ProximityPlacementGroup is valid inputProximityPlacementGroup.ProximityPlacementGroupType = ProximityPlacementGroupType.Standard; expectedProximityPlacementGroup = m_CrpClient.ProximityPlacementGroups.CreateOrUpdate( m_resourceGroup1Name, ProximityPlacementGroupName, inputProximityPlacementGroup); ValidateProximityPlacementGroup(inputProximityPlacementGroup, expectedProximityPlacementGroup, ProximityPlacementGroupName); // Get and expect success. expectedProximityPlacementGroup = m_CrpClient.ProximityPlacementGroups.Get(m_resourceGroup1Name, ProximityPlacementGroupName); ValidateProximityPlacementGroup(inputProximityPlacementGroup, expectedProximityPlacementGroup, ProximityPlacementGroupName); // Clean up m_CrpClient.ProximityPlacementGroups.Delete(m_resourceGroup1Name, ProximityPlacementGroupName); }
private async void ValidateResults(ProximityPlacementGroup outputProximityPlacementGroup, ProximityPlacementGroup inputProximityPlacementGroup, string resourceGroupName, string inputProximityPlacementGroupName) { string expectedProximityPlacementGroupId = Helpers.GetProximityPlacementGroupRef(m_subId, resourceGroupName, inputProximityPlacementGroupName); Assert.True(outputProximityPlacementGroup.Name == inputProximityPlacementGroupName, "ProximityPlacementGroup.Name mismatch between request and response."); Assert.True(outputProximityPlacementGroup.Location.ToLower() == this.m_location.ToLower() || outputProximityPlacementGroup.Location.ToLower() == inputProximityPlacementGroup.Location.ToLower(), "ProximityPlacementGroup.Location mismatch between request and response."); ValidateProximityPlacementGroup(inputProximityPlacementGroup, outputProximityPlacementGroup, inputProximityPlacementGroupName); // GET ProximityPlacementGroup var getResponse = (await ProximityPlacementGroupsOperations.GetAsync(resourceGroupName, inputProximityPlacementGroupName)).Value; ValidateProximityPlacementGroup(inputProximityPlacementGroup, getResponse, inputProximityPlacementGroupName); }
private void ValidateProximityPlacementGroup(ProximityPlacementGroup expectedProximityPlacementGroup, ProximityPlacementGroup outputProximityPlacementGroup, string expectedProximityPlacementGroupName) { Assert.True(outputProximityPlacementGroup != null, "ProximityPlacementGroup is null in response."); Assert.True(expectedProximityPlacementGroupName == outputProximityPlacementGroup.Name, "ProximityPlacementGroup.Name in response mismatch with expected value."); Assert.True( outputProximityPlacementGroup.Type == ApiConstants.ResourceProviderNamespace + "/" + ApiConstants.ProximityPlacementGroups, "ProximityPlacementGroup.Type in response mismatch with expected value."); Assert.True( expectedProximityPlacementGroup.ProximityPlacementGroupType == outputProximityPlacementGroup.ProximityPlacementGroupType, "ProximityPlacementGroup.ProximityPlacementGroupType in response mismatch with expected value."); void VerifySubResource(IReadOnlyList <Azure.ResourceManager.Compute.Models.SubResourceWithColocationStatus> inResource, IReadOnlyList <Azure.ResourceManager.Compute.Models.SubResourceWithColocationStatus> outResource, string subResourceTypeName) { if (inResource == null) { Assert.True(outResource == null || outResource.Count == 0, $"{subResourceTypeName} reference in response should be null/empty."); } else { List <string> inResourceIds = inResource.Select(input => input.Id).ToList(); List <string> outResourceIds = outResource.Select(output => output.Id).ToList(); Assert.True(inResourceIds.Count == outResourceIds.Count, $"Number of {subResourceTypeName} reference in response do not match with expected value."); Assert.True(0 == inResourceIds.Except(outResourceIds, StringComparer.OrdinalIgnoreCase).ToList().Count, $"Response has some unexpected {subResourceTypeName}."); } } VerifySubResource(expectedProximityPlacementGroup.AvailabilitySets, outputProximityPlacementGroup.AvailabilitySets, "AvailabilitySet"); VerifySubResource(expectedProximityPlacementGroup.VirtualMachines, outputProximityPlacementGroup.VirtualMachines, "VirtualMachine"); VerifySubResource(expectedProximityPlacementGroup.VirtualMachineScaleSets, outputProximityPlacementGroup.VirtualMachineScaleSets, "VirtualMachineScaleSet"); Assert.True(expectedProximityPlacementGroup.Tags != null, "Expected ProximityPlacementGroup tags should not be null."); Assert.True(outputProximityPlacementGroup.Tags != null, "ProximityPlacementGroup tags in response should not be null."); Assert.True(expectedProximityPlacementGroup.Tags.Count == outputProximityPlacementGroup.Tags.Count, "Number of tags in response do not match with expected value."); foreach (var tag in expectedProximityPlacementGroup.Tags) { string key = tag.Key; Assert.True(expectedProximityPlacementGroup.Tags[key] == outputProximityPlacementGroup.Tags[key], "Unexpected ProximityPlacementGroup tag is found in response."); } }
private void VerifyPutPatchGetAndDeleteWithNonDefaultValues_Success() { var tags = new Dictionary <string, string>() { { "RG", "rg" }, { "testTag", "1" } }; var inputProximityPlacementGroup = new ProximityPlacementGroup(m_location) { Tags = tags, ProximityPlacementGroupType = ProximityPlacementGroupType.Ultra }; var expectedProximityPlacementGroup = new ProximityPlacementGroup(m_location) { Tags = tags, ProximityPlacementGroupType = ProximityPlacementGroupType.Ultra }; VerifyPutPatchGetAndDeleteOperations_Scenarios(inputProximityPlacementGroup, expectedProximityPlacementGroup); }
private void VerifyPutPatchGetAndDeleteWithDefaultValues_Success() { var proximityPlacementGroupName = Recording.GenerateAssetName("testppg"); var tags = new Dictionary <string, string>() { { "RG", "rg" }, { "testTag", "1" } }; var inputProximityPlacementGroup = new ProximityPlacementGroup(m_location); inputProximityPlacementGroup.Tags.InitializeFrom(tags); var expectedProximityPlacementGroup = new ProximityPlacementGroup(m_location) { ProximityPlacementGroupType = ProximityPlacementGroupType.Standard }; expectedProximityPlacementGroup.Tags.InitializeFrom(tags); VerifyPutPatchGetAndDeleteOperations_Scenarios(inputProximityPlacementGroup, expectedProximityPlacementGroup); }
private void VerifyPutPatchGetAndDeleteWithDefaultValues_Success() { var proximityPlacementGroupName = ComputeManagementTestUtilities.GenerateName("testppg"); var tags = new Dictionary <string, string>() { { "RG", "rg" }, { "testTag", "1" } }; var inputProximityPlacementGroup = new ProximityPlacementGroup { Location = m_location, Tags = tags }; var expectedProximityPlacementGroup = new ProximityPlacementGroup { Location = m_location, Tags = tags, ProximityPlacementGroupType = ProximityPlacementGroupType.Standard }; VerifyPutPatchGetAndDeleteOperations_Scenarios(inputProximityPlacementGroup, expectedProximityPlacementGroup); }
internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string proximityPlacementGroupName, ProximityPlacementGroup parameters) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Put; var uri = new RawRequestUriBuilder(); uri.Reset(endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Compute/proximityPlacementGroups/", false); uri.AppendPath(proximityPlacementGroupName, true); uri.AppendQuery("api-version", "2019-12-01", true); request.Uri = uri; request.Headers.Add("Content-Type", "application/json"); using var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(parameters); request.Content = content; return(message); }
private void TestScaleSetOperationsInternal(MockContext context, string vmSize = null, bool hasManagedDisks = false, bool useVmssExtension = true, bool hasDiffDisks = false, IList <string> zones = null, int?osDiskSizeInGB = null, bool isPpgScenario = false, bool?enableUltraSSD = false, Action <VirtualMachineScaleSet> vmScaleSetCustomizer = null, Action <VirtualMachineScaleSet> vmScaleSetValidator = null, string diskEncryptionSetId = null, bool?encryptionAtHostEnabled = null, bool isAutomaticPlacementOnDedicatedHostGroupScenario = false, int?faultDomainCount = null, int?capacity = null, bool shouldOverProvision = true, bool validateVmssVMInstanceView = false, ImageReference imageReference = null, bool validateListSku = true, bool deleteAsPartOfTest = true) { EnsureClientsInitialized(context); ImageReference imageRef = imageReference ?? GetPlatformVMImage(useWindowsImage: true); // Create resource group var rgName = TestUtilities.GenerateName(TestPrefix); var vmssName = TestUtilities.GenerateName("vmss"); string storageAccountName = TestUtilities.GenerateName(TestPrefix); VirtualMachineScaleSet inputVMScaleSet; VirtualMachineScaleSetExtensionProfile extensionProfile = new VirtualMachineScaleSetExtensionProfile() { Extensions = new List <VirtualMachineScaleSetExtension>() { GetTestVMSSVMExtension(autoUpdateMinorVersion: false), } }; try { var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName); m_CrpClient.VirtualMachineScaleSets.Delete(rgName, "VMScaleSetDoesNotExist"); string ppgId = null; string ppgName = null; if (isPpgScenario) { ppgName = ComputeManagementTestUtilities.GenerateName("ppgtest"); ppgId = CreateProximityPlacementGroup(rgName, ppgName); } string dedicatedHostGroupName = null, dedicatedHostName = null, dedicatedHostGroupReferenceId = null, dedicatedHostReferenceId = null; if (isAutomaticPlacementOnDedicatedHostGroupScenario) { dedicatedHostGroupName = ComputeManagementTestUtilities.GenerateName("dhgtest"); dedicatedHostName = ComputeManagementTestUtilities.GenerateName("dhtest"); dedicatedHostGroupReferenceId = Helpers.GetDedicatedHostGroupRef(m_subId, rgName, dedicatedHostGroupName); dedicatedHostReferenceId = Helpers.GetDedicatedHostRef(m_subId, rgName, dedicatedHostGroupName, dedicatedHostName); } VirtualMachineScaleSet getResponse = CreateVMScaleSet_NoAsyncTracking( rgName, vmssName, storageAccountOutput, imageRef, out inputVMScaleSet, useVmssExtension ? extensionProfile : null, (vmScaleSet) => { vmScaleSet.Overprovision = shouldOverProvision; if (!String.IsNullOrEmpty(vmSize)) { vmScaleSet.Sku.Name = vmSize; } vmScaleSetCustomizer?.Invoke(vmScaleSet); }, createWithManagedDisks: hasManagedDisks, hasDiffDisks: hasDiffDisks, zones: zones, osDiskSizeInGB: osDiskSizeInGB, ppgId: ppgId, enableUltraSSD: enableUltraSSD, diskEncryptionSetId: diskEncryptionSetId, encryptionAtHostEnabled: encryptionAtHostEnabled, faultDomainCount: faultDomainCount, capacity: capacity, dedicatedHostGroupReferenceId: dedicatedHostGroupReferenceId, dedicatedHostGroupName: dedicatedHostGroupName, dedicatedHostName: dedicatedHostName); if (diskEncryptionSetId != null) { Assert.True(getResponse.VirtualMachineProfile.StorageProfile.OsDisk.ManagedDisk.DiskEncryptionSet != null, "OsDisk.ManagedDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getResponse.VirtualMachineProfile.StorageProfile.OsDisk.ManagedDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "OsDisk.ManagedDisk.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); Assert.Equal(1, getResponse.VirtualMachineProfile.StorageProfile.DataDisks.Count); Assert.True(getResponse.VirtualMachineProfile.StorageProfile.DataDisks[0].ManagedDisk.DiskEncryptionSet != null, ".DataDisks.ManagedDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getResponse.VirtualMachineProfile.StorageProfile.DataDisks[0].ManagedDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "DataDisks.ManagedDisk.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); } if (encryptionAtHostEnabled != null) { Assert.True(getResponse.VirtualMachineProfile.SecurityProfile.EncryptionAtHost == encryptionAtHostEnabled.Value, "SecurityProfile.EncryptionAtHost is not same as expected"); } ValidateVMScaleSet(inputVMScaleSet, getResponse, hasManagedDisks, ppgId: ppgId, dedicatedHostGroupReferenceId: dedicatedHostGroupReferenceId); var getInstanceViewResponse = m_CrpClient.VirtualMachineScaleSets.GetInstanceView(rgName, vmssName); Assert.NotNull(getInstanceViewResponse); ValidateVMScaleSetInstanceView(inputVMScaleSet, getInstanceViewResponse); if (isPpgScenario) { ProximityPlacementGroup outProximityPlacementGroup = m_CrpClient.ProximityPlacementGroups.Get(rgName, ppgName); Assert.Equal(1, outProximityPlacementGroup.VirtualMachineScaleSets.Count); string expectedVmssReferenceId = Helpers.GetVMScaleSetReferenceId(m_subId, rgName, vmssName); Assert.Equal(expectedVmssReferenceId, outProximityPlacementGroup.VirtualMachineScaleSets.First().Id, StringComparer.OrdinalIgnoreCase); } var listResponse = m_CrpClient.VirtualMachineScaleSets.List(rgName); ValidateVMScaleSet(inputVMScaleSet, listResponse.FirstOrDefault(x => x.Name == vmssName), hasManagedDisks); if (validateListSku) { var listSkusResponse = m_CrpClient.VirtualMachineScaleSets.ListSkus(rgName, vmssName); Assert.NotNull(listSkusResponse); Assert.False(listSkusResponse.Count() == 0); } if (zones != null) { var query = new Microsoft.Rest.Azure.OData.ODataQuery <VirtualMachineScaleSetVM>(); query.SetFilter(vm => vm.LatestModelApplied == true); var listVMsResponse = m_CrpClient.VirtualMachineScaleSetVMs.List(rgName, vmssName, query); Assert.False(listVMsResponse == null, "VMScaleSetVMs not returned"); Assert.True(listVMsResponse.Count() == inputVMScaleSet.Sku.Capacity); foreach (var vmScaleSetVM in listVMsResponse) { string instanceId = vmScaleSetVM.InstanceId; var getVMResponse = m_CrpClient.VirtualMachineScaleSetVMs.Get(rgName, vmssName, instanceId); ValidateVMScaleSetVM(inputVMScaleSet, instanceId, getVMResponse, hasManagedDisks); } } if (validateVmssVMInstanceView) { VirtualMachineScaleSetVMInstanceView vmssVMInstanceView = m_CrpClient.VirtualMachineScaleSetVMs.GetInstanceView(rgName, vmssName, "0"); ValidateVMScaleSetVMInstanceView(vmssVMInstanceView, hasManagedDisks, dedicatedHostReferenceId); } vmScaleSetValidator?.Invoke(getResponse); if (deleteAsPartOfTest) { m_CrpClient.VirtualMachineScaleSets.Delete(rgName, vmssName); } } finally { if (deleteAsPartOfTest) { m_ResourcesClient.ResourceGroups.Delete(rgName); } else { // Fire and forget. No need to wait for RG deletion completion m_ResourcesClient.ResourceGroups.BeginDelete(rgName); } } }
private void TestVMScenarioOperationsInternal(string methodName, bool hasManagedDisks = false, IList <string> zones = null, string vmSize = "Standard_A1_v2", string osDiskStorageAccountType = "Standard_LRS", string dataDiskStorageAccountType = "Standard_LRS", bool?writeAcceleratorEnabled = null, bool hasDiffDisks = false, bool callUpdateVM = false, bool isPpgScenario = false, string diskEncryptionSetId = null, bool?encryptionAtHostEnabled = null, string securityType = null, bool isAutomaticPlacementOnDedicatedHostGroupScenario = false, ImageReference imageReference = null, bool validateListAvailableSize = true) { using (MockContext context = MockContext.Start(this.GetType(), methodName)) { EnsureClientsInitialized(context); ImageReference imageRef = imageReference ?? GetPlatformVMImage(useWindowsImage: true); const string expectedOSName = "Windows Server 2012 R2 Datacenter", expectedOSVersion = "Microsoft Windows NT 6.3.9600.0", expectedComputerName = ComputerName; // Create resource group var rgName = ComputeManagementTestUtilities.GenerateName(TestPrefix); string storageAccountName = ComputeManagementTestUtilities.GenerateName(TestPrefix); string asName = ComputeManagementTestUtilities.GenerateName("as"); string ppgName = null, expectedPpgReferenceId = null; string dedicatedHostGroupName = null, dedicatedHostName = null, dedicatedHostGroupReferenceId = null, dedicatedHostReferenceId = null; if (isPpgScenario) { ppgName = ComputeManagementTestUtilities.GenerateName("ppgtest"); expectedPpgReferenceId = Helpers.GetProximityPlacementGroupRef(m_subId, rgName, ppgName); } if (isAutomaticPlacementOnDedicatedHostGroupScenario) { dedicatedHostGroupName = ComputeManagementTestUtilities.GenerateName("dhgtest"); dedicatedHostName = ComputeManagementTestUtilities.GenerateName("dhtest"); dedicatedHostGroupReferenceId = Helpers.GetDedicatedHostGroupRef(m_subId, rgName, dedicatedHostGroupName); dedicatedHostReferenceId = Helpers.GetDedicatedHostRef(m_subId, rgName, dedicatedHostGroupName, dedicatedHostName); } VirtualMachine inputVM; try { if (!hasManagedDisks) { CreateStorageAccount(rgName, storageAccountName); } CreateVM(rgName, asName, storageAccountName, imageRef, out inputVM, hasManagedDisks: hasManagedDisks, hasDiffDisks: hasDiffDisks, vmSize: vmSize, osDiskStorageAccountType: osDiskStorageAccountType, dataDiskStorageAccountType: dataDiskStorageAccountType, writeAcceleratorEnabled: writeAcceleratorEnabled, zones: zones, ppgName: ppgName, diskEncryptionSetId: diskEncryptionSetId, encryptionAtHostEnabled: encryptionAtHostEnabled, securityType: securityType, dedicatedHostGroupReferenceId: dedicatedHostGroupReferenceId, dedicatedHostGroupName: dedicatedHostGroupName, dedicatedHostName: dedicatedHostName); // Instance view is not completely populated just after VM is provisioned. So we wait here for a few minutes to // allow GA blob to populate. ComputeManagementTestUtilities.WaitMinutes(5); var getVMWithInstanceViewResponse = m_CrpClient.VirtualMachines.Get(rgName, inputVM.Name, InstanceViewTypes.InstanceView); Assert.True(getVMWithInstanceViewResponse != null, "VM in Get"); if (diskEncryptionSetId != null) { Assert.True(getVMWithInstanceViewResponse.StorageProfile.OsDisk.ManagedDisk.DiskEncryptionSet != null, "OsDisk.ManagedDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getVMWithInstanceViewResponse.StorageProfile.OsDisk.ManagedDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "OsDisk.ManagedDisk.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); Assert.Equal(1, getVMWithInstanceViewResponse.StorageProfile.DataDisks.Count); Assert.True(getVMWithInstanceViewResponse.StorageProfile.DataDisks[0].ManagedDisk.DiskEncryptionSet != null, ".DataDisks.ManagedDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getVMWithInstanceViewResponse.StorageProfile.DataDisks[0].ManagedDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "DataDisks.ManagedDisk.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); } ValidateVMInstanceView(inputVM, getVMWithInstanceViewResponse, hasManagedDisks, expectedComputerName, expectedOSName, expectedOSVersion, dedicatedHostReferenceId); var getVMInstanceViewResponse = m_CrpClient.VirtualMachines.InstanceView(rgName, inputVM.Name); Assert.True(getVMInstanceViewResponse != null, "VM in InstanceView"); ValidateVMInstanceView(inputVM, getVMInstanceViewResponse, hasManagedDisks, expectedComputerName, expectedOSName, expectedOSVersion, dedicatedHostReferenceId); bool hasUserDefinedAS = inputVM.AvailabilitySet != null; string expectedVMReferenceId = Helpers.GetVMReferenceId(m_subId, rgName, inputVM.Name); var listResponse = m_CrpClient.VirtualMachines.List(rgName); ValidateVM(inputVM, listResponse.FirstOrDefault(x => x.Name == inputVM.Name), expectedVMReferenceId, hasManagedDisks, hasUserDefinedAS, writeAcceleratorEnabled, hasDiffDisks, expectedPpgReferenceId: expectedPpgReferenceId, encryptionAtHostEnabled: encryptionAtHostEnabled, expectedDedicatedHostGroupReferenceId: dedicatedHostGroupReferenceId); if (validateListAvailableSize) { var listVMSizesResponse = m_CrpClient.VirtualMachines.ListAvailableSizes(rgName, inputVM.Name); Helpers.ValidateVirtualMachineSizeListResponse(listVMSizesResponse, hasAZ: zones != null, writeAcceleratorEnabled: writeAcceleratorEnabled, hasDiffDisks: hasDiffDisks); listVMSizesResponse = m_CrpClient.AvailabilitySets.ListAvailableSizes(rgName, asName); Helpers.ValidateVirtualMachineSizeListResponse(listVMSizesResponse, hasAZ: zones != null, writeAcceleratorEnabled: writeAcceleratorEnabled, hasDiffDisks: hasDiffDisks); } if (securityType != null && securityType.Equals("TrustedLaunch")) { Assert.True(inputVM.SecurityProfile.UefiSettings.VTpmEnabled); Assert.True(inputVM.SecurityProfile.UefiSettings.SecureBootEnabled); } if (isPpgScenario) { ProximityPlacementGroup outProximityPlacementGroup = m_CrpClient.ProximityPlacementGroups.Get(rgName, ppgName); string expectedAvSetReferenceId = Helpers.GetAvailabilitySetRef(m_subId, rgName, asName); Assert.Equal(1, outProximityPlacementGroup.VirtualMachines.Count); Assert.Equal(1, outProximityPlacementGroup.AvailabilitySets.Count); Assert.Equal(expectedVMReferenceId, outProximityPlacementGroup.VirtualMachines.First().Id, StringComparer.OrdinalIgnoreCase); Assert.Equal(expectedAvSetReferenceId, outProximityPlacementGroup.AvailabilitySets.First().Id, StringComparer.OrdinalIgnoreCase); } if (callUpdateVM) { VirtualMachineUpdate updateParams = new VirtualMachineUpdate() { Tags = inputVM.Tags }; string updateKey = "UpdateTag"; updateParams.Tags.Add(updateKey, "UpdateTagValue"); VirtualMachine updateResponse = m_CrpClient.VirtualMachines.Update(rgName, inputVM.Name, updateParams); Assert.True(updateResponse.Tags.ContainsKey(updateKey)); } } finally { // Fire and forget. No need to wait for RG deletion completion try { m_ResourcesClient.ResourceGroups.BeginDelete(rgName); } catch (Exception e) { // Swallow this exception so that the original exception is thrown Console.WriteLine(e); } } } }
// Make sure proximityPlacementGroup across resource groups are listed successfully and proximityPlacementGroups in a resource groups are listed successfully private async Task VerifyListProximityPlacementGroups() { string resourceGroup2Name = m_baseResourceGroupName + "_2"; string baseInputProximityPlacementGroupName = Recording.GenerateAssetName("testppg"); string proximityPlacementGroup1Name = baseInputProximityPlacementGroupName + "_1"; string proximityPlacementGroup2Name = baseInputProximityPlacementGroupName + "_2"; ProximityPlacementGroup inputProximityPlacementGroup1 = new ProximityPlacementGroup(m_location) { Tags = { { "RG1", "rg1" }, { "testTag", "1" }, }, }; ProximityPlacementGroup outputProximityPlacementGroup1 = await ProximityPlacementGroupsOperations.CreateOrUpdateAsync( m_resourceGroup1Name, proximityPlacementGroup1Name, inputProximityPlacementGroup1); await ResourceGroupsOperations.CreateOrUpdateAsync( resourceGroup2Name, new ResourceGroup(m_location) { Tags = { { resourceGroup2Name, Recording.UtcNow.ToString("u") } } }); ProximityPlacementGroup inputProximityPlacementGroup2 = new ProximityPlacementGroup(m_location) { Tags = { { "RG2", "rg2" }, { "testTag", "2" }, }, }; ProximityPlacementGroup outputProximityPlacementGroup2 = await ProximityPlacementGroupsOperations.CreateOrUpdateAsync( resourceGroup2Name, proximityPlacementGroup2Name, inputProximityPlacementGroup2); //verify proximityPlacementGroup across resource groups are listed successfully //IPage<ProximityPlacementGroup> response = await ProximityPlacementGroupsClient.ListBySubscription(); IList <ProximityPlacementGroup> response = await(ProximityPlacementGroupsOperations.ListBySubscriptionAsync()).ToEnumerableAsync(); //Assert.True(response.NextPageLink == null, "NextPageLink should be null in response."); int validationCount = 0; foreach (ProximityPlacementGroup proximityPlacementGroup in response) { if (proximityPlacementGroup.Name == proximityPlacementGroup1Name) { //PPG is created using default value, updating the default value in input for validation of expected returned value. inputProximityPlacementGroup1.ProximityPlacementGroupType = ProximityPlacementGroupType.Standard; ValidateResults(outputProximityPlacementGroup1, inputProximityPlacementGroup1, m_resourceGroup1Name, proximityPlacementGroup1Name); validationCount++; } else if (proximityPlacementGroup.Name == proximityPlacementGroup2Name) { //PPG is created using default value, updating the default value in input for validation of expected returned value. inputProximityPlacementGroup2.ProximityPlacementGroupType = ProximityPlacementGroupType.Standard; ValidateResults(outputProximityPlacementGroup2, inputProximityPlacementGroup2, resourceGroup2Name, proximityPlacementGroup2Name); validationCount++; } } Assert.True(validationCount == 2, "Not all ProximityPlacementGroups are returned in response."); //verify proximityPlacementGroups in a resource groups are listed successfully response = await(ProximityPlacementGroupsOperations.ListByResourceGroupAsync(m_resourceGroup1Name)).ToEnumerableAsync(); ValidateResults(outputProximityPlacementGroup1, inputProximityPlacementGroup1, m_resourceGroup1Name, proximityPlacementGroup1Name); response = await(ProximityPlacementGroupsOperations.ListByResourceGroupAsync(resourceGroup2Name)).ToEnumerableAsync(); ValidateResults(outputProximityPlacementGroup2, inputProximityPlacementGroup2, resourceGroup2Name, proximityPlacementGroup2Name); }
private async Task VerifyProximityPlacementGroupColocationStatusView() { var ppgName = Recording.GenerateAssetName("testppg"); string asName = Recording.GenerateAssetName("testas"); string vmssName = Recording.GenerateAssetName("testvmss"); string storageAccountName = Recording.GenerateAssetName(TestPrefix); ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true); var inputProximityPlacementGroup = new ProximityPlacementGroup(m_location) { Tags = { { "RG", "rg" }, { "testTag", "1" }, }, ProximityPlacementGroupType = ProximityPlacementGroupType.Standard }; var expectedProximityPlacementGroup = new ProximityPlacementGroup(m_location) { Tags = { { "RG", "rg" }, { "testTag", "1" }, }, ProximityPlacementGroupType = ProximityPlacementGroupType.Standard }; // Create and expect success. ProximityPlacementGroup outProximityPlacementGroup = await ProximityPlacementGroupsOperations.CreateOrUpdateAsync(m_resourceGroup1Name, ppgName, inputProximityPlacementGroup); ValidateProximityPlacementGroup(expectedProximityPlacementGroup, outProximityPlacementGroup, ppgName); VirtualMachine inputVM; var returnTwoVM = await CreateVM(m_resourceGroup1Name, asName, storageAccountName, imageRef, hasManagedDisks : true, hasDiffDisks : false, vmSize : "Standard_A0", osDiskStorageAccountType : "Standard_LRS", dataDiskStorageAccountType : "Standard_LRS", writeAcceleratorEnabled : false, zones : null, ppgName : ppgName, diskEncryptionSetId : null); VirtualMachine outVM = returnTwoVM.Item1; inputVM = returnTwoVM.Item2; // Get and expect success. outProximityPlacementGroup = await ProximityPlacementGroupsOperations.GetAsync(m_resourceGroup1Name, ppgName, includeColocationStatus : "true"); InstanceViewStatus expectedInstanceViewStatus = new InstanceViewStatus { Code = "ColocationStatus/Aligned", Level = StatusLevelTypes.Info, DisplayStatus = "Aligned", Message = "All resources in the proximity placement group are aligned." }; expectedProximityPlacementGroup = new ProximityPlacementGroup(null, null, null, m_location, new Dictionary <string, string>() { { "RG", "rg" }, { "testTag", "1" }, }, ProximityPlacementGroupType.Standard, new List <SubResourceWithColocationStatus> { new SubResourceWithColocationStatus(outVM.Id, null) }, null, new List <SubResourceWithColocationStatus> { new SubResourceWithColocationStatus(outVM.AvailabilitySet.Id, null) }, null ); ValidateProximityPlacementGroup(expectedProximityPlacementGroup, outProximityPlacementGroup, ppgName); ValidateColocationStatus(expectedInstanceViewStatus, outProximityPlacementGroup.ColocationStatus); }
/// <summary> /// Create or update a proximity placement 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='proximityPlacementGroupName'> /// The name of the proximity placement group. /// </param> /// <param name='parameters'> /// Parameters supplied to the Create Proximity Placement Group operation. /// </param> public static ProximityPlacementGroup CreateOrUpdate(this IProximityPlacementGroupsOperations operations, string resourceGroupName, string proximityPlacementGroupName, ProximityPlacementGroup parameters) { return(operations.CreateOrUpdateAsync(resourceGroupName, proximityPlacementGroupName, parameters).GetAwaiter().GetResult()); }
private async void VerifyPutPatchGetAndDeleteOperations_Scenarios(ProximityPlacementGroup inputProximityPlacementGroup, ProximityPlacementGroup expectedProximityPlacementGroup) { var proximityPlacementGroupName = Recording.GenerateAssetName("testppg"); // Create and expect success. ProximityPlacementGroup outProximityPlacementGroup = await ProximityPlacementGroupsOperations.CreateOrUpdateAsync(m_resourceGroup1Name, proximityPlacementGroupName, inputProximityPlacementGroup); ValidateProximityPlacementGroup(expectedProximityPlacementGroup, outProximityPlacementGroup, proximityPlacementGroupName); // Update and expect success. inputProximityPlacementGroup.Tags.Add("UpdateTag1", "updateValue1"); outProximityPlacementGroup = await ProximityPlacementGroupsOperations.CreateOrUpdateAsync(m_resourceGroup1Name, proximityPlacementGroupName, inputProximityPlacementGroup); ValidateProximityPlacementGroup(expectedProximityPlacementGroup, outProximityPlacementGroup, proximityPlacementGroupName); // Get and expect success. outProximityPlacementGroup = await ProximityPlacementGroupsOperations.GetAsync(m_resourceGroup1Name, proximityPlacementGroupName); ValidateProximityPlacementGroup(expectedProximityPlacementGroup, outProximityPlacementGroup, proximityPlacementGroupName); // Put and expect failure try { //Updating ProximityPlacementGroupType in inputProximityPlacementGroup for a Update call. if (expectedProximityPlacementGroup.ProximityPlacementGroupType == ProximityPlacementGroupType.Standard) { inputProximityPlacementGroup.ProximityPlacementGroupType = ProximityPlacementGroupType.Ultra; } else { inputProximityPlacementGroup.ProximityPlacementGroupType = ProximityPlacementGroupType.Standard; } outProximityPlacementGroup = null; outProximityPlacementGroup = await ProximityPlacementGroupsOperations.CreateOrUpdateAsync(m_resourceGroup1Name, proximityPlacementGroupName, inputProximityPlacementGroup); } catch (Exception ex) { //if (ex.StatusCode == HttpStatusCode.Conflict) //{ // Assert.AreEqual("Changing property 'proximityPlacementGroup.properties.proximityPlacementGroupType' is not allowed.", ex.Message ); //} //else if (ex.Response.StatusCode == HttpStatusCode.BadRequest) //{ // Assert.Equal("The subscription is not registered for private preview of Ultra Proximity Placement Groups.", ex.Message, StringComparer.OrdinalIgnoreCase); //} //else //{ // Console.WriteLine($"Expecting HttpStatusCode { HttpStatusCode.Conflict} or { HttpStatusCode.BadRequest}, while actual HttpStatusCode is { ex.Response.StatusCode}."); // throw; //} Console.WriteLine($"Expecting HttpStatusCode { HttpStatusCode.Conflict} or { HttpStatusCode.BadRequest}, while actual HttpStatusCode is { ex.Message}."); throw; } Assert.True(outProximityPlacementGroup == null, "ProximityPlacementGroup in response should be null."); //Patch and expect success UpdateResource proximityPlacementGroupUpdate = new UpdateResource(); proximityPlacementGroupUpdate.Tags.InitializeFrom(inputProximityPlacementGroup.Tags); //Note: Same Tags object is referred in proximityPlacementGroupUpdate and expectedProximityPlacementGroup, //hence this will also update tags in expectedProximityPlacementGroup. proximityPlacementGroupUpdate.Tags.Add("UpdateTag2", "updateValue2"); outProximityPlacementGroup = await ProximityPlacementGroupsOperations.UpdateAsync(m_resourceGroup1Name, proximityPlacementGroupName, proximityPlacementGroupUpdate); ValidateProximityPlacementGroup(expectedProximityPlacementGroup, outProximityPlacementGroup, proximityPlacementGroupName); // Clean up await ProximityPlacementGroupsOperations.DeleteAsync(m_resourceGroup1Name, proximityPlacementGroupName); }
private void TestScaleSetOperationsInternal(MockContext context, string vmSize = null, bool hasManagedDisks = false, bool useVmssExtension = true, bool hasDiffDisks = false, IList <string> zones = null, int?osDiskSizeInGB = null, bool isPpgScenario = false, bool?enableUltraSSD = false, Action <VirtualMachineScaleSet> vmScaleSetCustomizer = null, Action <VirtualMachineScaleSet> vmScaleSetValidator = null, string diskEncryptionSetId = null) { EnsureClientsInitialized(context); ImageReference imageRef = GetPlatformVMImage(useWindowsImage: true); // Create resource group var rgName = TestUtilities.GenerateName(TestPrefix); var vmssName = TestUtilities.GenerateName("vmss"); string storageAccountName = TestUtilities.GenerateName(TestPrefix); VirtualMachineScaleSet inputVMScaleSet; VirtualMachineScaleSetExtensionProfile extensionProfile = new VirtualMachineScaleSetExtensionProfile() { Extensions = new List <VirtualMachineScaleSetExtension>() { GetTestVMSSVMExtension(), } }; try { var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName); m_CrpClient.VirtualMachineScaleSets.Delete(rgName, "VMScaleSetDoesNotExist"); string ppgId = null; string ppgName = null; if (isPpgScenario) { ppgName = ComputeManagementTestUtilities.GenerateName("ppgtest"); ppgId = CreateProximityPlacementGroup(rgName, ppgName); } VirtualMachineScaleSet getResponse = CreateVMScaleSet_NoAsyncTracking( rgName, vmssName, storageAccountOutput, imageRef, out inputVMScaleSet, useVmssExtension ? extensionProfile : null, (vmScaleSet) => { vmScaleSet.Overprovision = true; if (!String.IsNullOrEmpty(vmSize)) { vmScaleSet.Sku.Name = vmSize; } vmScaleSetCustomizer?.Invoke(vmScaleSet); }, createWithManagedDisks: hasManagedDisks, hasDiffDisks: hasDiffDisks, zones: zones, osDiskSizeInGB: osDiskSizeInGB, ppgId: ppgId, enableUltraSSD: enableUltraSSD, diskEncryptionSetId: diskEncryptionSetId); if (diskEncryptionSetId != null) { Assert.True(getResponse.VirtualMachineProfile.StorageProfile.OsDisk.ManagedDisk.DiskEncryptionSet != null, "OsDisk.ManagedDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getResponse.VirtualMachineProfile.StorageProfile.OsDisk.ManagedDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "OsDisk.ManagedDisk.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); Assert.Equal(1, getResponse.VirtualMachineProfile.StorageProfile.DataDisks.Count); Assert.True(getResponse.VirtualMachineProfile.StorageProfile.DataDisks[0].ManagedDisk.DiskEncryptionSet != null, ".DataDisks.ManagedDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getResponse.VirtualMachineProfile.StorageProfile.DataDisks[0].ManagedDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "DataDisks.ManagedDisk.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); } ValidateVMScaleSet(inputVMScaleSet, getResponse, hasManagedDisks, ppgId: ppgId); var getInstanceViewResponse = m_CrpClient.VirtualMachineScaleSets.GetInstanceView(rgName, vmssName); Assert.NotNull(getInstanceViewResponse); ValidateVMScaleSetInstanceView(inputVMScaleSet, getInstanceViewResponse); if (isPpgScenario) { ProximityPlacementGroup outProximityPlacementGroup = m_CrpClient.ProximityPlacementGroups.Get(rgName, ppgName); Assert.Equal(1, outProximityPlacementGroup.VirtualMachineScaleSets.Count); string expectedVmssReferenceId = Helpers.GetVMScaleSetReferenceId(m_subId, rgName, vmssName); Assert.Equal(expectedVmssReferenceId, outProximityPlacementGroup.VirtualMachineScaleSets.First().Id, StringComparer.OrdinalIgnoreCase); } var listResponse = m_CrpClient.VirtualMachineScaleSets.List(rgName); ValidateVMScaleSet(inputVMScaleSet, listResponse.FirstOrDefault(x => x.Name == vmssName), hasManagedDisks); var listSkusResponse = m_CrpClient.VirtualMachineScaleSets.ListSkus(rgName, vmssName); Assert.NotNull(listSkusResponse); Assert.False(listSkusResponse.Count() == 0); if (zones != null) { var query = new Microsoft.Rest.Azure.OData.ODataQuery <VirtualMachineScaleSetVM>(); query.SetFilter(vm => vm.LatestModelApplied == true); var listVMsResponse = m_CrpClient.VirtualMachineScaleSetVMs.List(rgName, vmssName, query); Assert.False(listVMsResponse == null, "VMScaleSetVMs not returned"); Assert.True(listVMsResponse.Count() == inputVMScaleSet.Sku.Capacity); foreach (var vmScaleSetVM in listVMsResponse) { string instanceId = vmScaleSetVM.InstanceId; var getVMResponse = m_CrpClient.VirtualMachineScaleSetVMs.Get(rgName, vmssName, instanceId); ValidateVMScaleSetVM(inputVMScaleSet, instanceId, getVMResponse, hasManagedDisks); } } vmScaleSetValidator?.Invoke(getResponse); m_CrpClient.VirtualMachineScaleSets.Delete(rgName, vmssName); } finally { //Cleanup the created resources. But don't wait since it takes too long, and it's not the purpose //of the test to cover deletion. CSM does persistent retrying over all RG resources. m_ResourcesClient.ResourceGroups.Delete(rgName); } }
// Make sure proximityPlacementGroup across resource groups are listed successfully and proximityPlacementGroups in a resource groups are listed successfully private void VerifyListProximityPlacementGroups() { string resourceGroup2Name = m_baseResourceGroupName + "_2"; string baseInputProximityPlacementGroupName = ComputeManagementTestUtilities.GenerateName("testppg"); string proximityPlacementGroup1Name = baseInputProximityPlacementGroupName + "_1"; string proximityPlacementGroup2Name = baseInputProximityPlacementGroupName + "_2"; try { ProximityPlacementGroup inputProximityPlacementGroup1 = new ProximityPlacementGroup { Location = m_location, Tags = new Dictionary <string, string>() { { "RG1", "rg1" }, { "testTag", "1" }, }, }; ProximityPlacementGroup outputProximityPlacementGroup1 = m_CrpClient.ProximityPlacementGroups.CreateOrUpdate( m_resourceGroup1Name, proximityPlacementGroup1Name, inputProximityPlacementGroup1); m_ResourcesClient.ResourceGroups.CreateOrUpdate( resourceGroup2Name, new ResourceGroup { Location = m_location, Tags = new Dictionary <string, string>() { { resourceGroup2Name, DateTime.UtcNow.ToString("u") } } }); ProximityPlacementGroup inputProximityPlacementGroup2 = new ProximityPlacementGroup { Location = m_location, Tags = new Dictionary <string, string>() { { "RG2", "rg2" }, { "testTag", "2" }, }, }; ProximityPlacementGroup outputProximityPlacementGroup2 = m_CrpClient.ProximityPlacementGroups.CreateOrUpdate( resourceGroup2Name, proximityPlacementGroup2Name, inputProximityPlacementGroup2); //verify proximityPlacementGroup across resource groups are listed successfully IPage <ProximityPlacementGroup> response = m_CrpClient.ProximityPlacementGroups.ListBySubscription(); Assert.True(response.NextPageLink == null, "NextPageLink should be null in response."); int validationCount = 0; foreach (ProximityPlacementGroup proximityPlacementGroup in response) { if (proximityPlacementGroup.Name == proximityPlacementGroup1Name) { //PPG is created using default value, updating the default value in input for validation of expected returned value. inputProximityPlacementGroup1.ProximityPlacementGroupType = ProximityPlacementGroupType.Standard; ValidateResults(outputProximityPlacementGroup1, inputProximityPlacementGroup1, m_resourceGroup1Name, proximityPlacementGroup1Name); validationCount++; } else if (proximityPlacementGroup.Name == proximityPlacementGroup2Name) { //PPG is created using default value, updating the default value in input for validation of expected returned value. inputProximityPlacementGroup2.ProximityPlacementGroupType = ProximityPlacementGroupType.Standard; ValidateResults(outputProximityPlacementGroup2, inputProximityPlacementGroup2, resourceGroup2Name, proximityPlacementGroup2Name); validationCount++; } } Assert.True(validationCount == 2, "Not all ProximityPlacementGroups are returned in response."); //verify proximityPlacementGroups in a resource groups are listed successfully response = m_CrpClient.ProximityPlacementGroups.ListByResourceGroup(m_resourceGroup1Name); ValidateResults(outputProximityPlacementGroup1, inputProximityPlacementGroup1, m_resourceGroup1Name, proximityPlacementGroup1Name); response = m_CrpClient.ProximityPlacementGroups.ListByResourceGroup(resourceGroup2Name); ValidateResults(outputProximityPlacementGroup2, inputProximityPlacementGroup2, resourceGroup2Name, proximityPlacementGroup2Name); } finally { m_ResourcesClient.ResourceGroups.Delete(resourceGroup2Name); // Delete ProximityPlacementGroup m_CrpClient.ProximityPlacementGroups.Delete(m_resourceGroup1Name, proximityPlacementGroup1Name); } }
private void VerifyProximityPlacementGroupColocationStatusView() { var ppgName = ComputeManagementTestUtilities.GenerateName("testppg"); string asName = ComputeManagementTestUtilities.GenerateName("testas"); string vmssName = ComputeManagementTestUtilities.GenerateName("testvmss"); string storageAccountName = ComputeManagementTestUtilities.GenerateName(TestPrefix); ImageReference imageRef = GetPlatformVMImage(useWindowsImage: true); var inputProximityPlacementGroup = new ProximityPlacementGroup { Location = m_location, Tags = new Dictionary <string, string>() { { "RG", "rg" }, { "testTag", "1" }, }, ProximityPlacementGroupType = ProximityPlacementGroupType.Standard }; var expectedProximityPlacementGroup = new ProximityPlacementGroup { Location = m_location, Tags = new Dictionary <string, string>() { { "RG", "rg" }, { "testTag", "1" }, }, ProximityPlacementGroupType = ProximityPlacementGroupType.Standard }; // Create and expect success. ProximityPlacementGroup outProximityPlacementGroup = m_CrpClient.ProximityPlacementGroups.CreateOrUpdate(m_resourceGroup1Name, ppgName, inputProximityPlacementGroup); ValidateProximityPlacementGroup(expectedProximityPlacementGroup, outProximityPlacementGroup, ppgName); VirtualMachine inputVM; VirtualMachine outVM = CreateVM(m_resourceGroup1Name, asName, storageAccountName, imageRef, out inputVM, hasManagedDisks: true, hasDiffDisks: false, vmSize: "Standard_A1_v2", osDiskStorageAccountType: "Standard_LRS", dataDiskStorageAccountType: "Standard_LRS", writeAcceleratorEnabled: false, zones: null, ppgName: ppgName, diskEncryptionSetId: null); // Get and expect success. outProximityPlacementGroup = m_CrpClient.ProximityPlacementGroups.Get(m_resourceGroup1Name, ppgName, includeColocationStatus: "true"); InstanceViewStatus expectedInstanceViewStatus = new InstanceViewStatus { Code = "ColocationStatus/Aligned", Level = StatusLevelTypes.Info, DisplayStatus = "Aligned", Message = "All resources in the proximity placement group are aligned." }; expectedProximityPlacementGroup = new ProximityPlacementGroup( m_location, tags: new Dictionary <string, string>() { { "RG", "rg" }, { "testTag", "1" }, }, proximityPlacementGroupType: ProximityPlacementGroupType.Standard, virtualMachines: new List <SubResourceWithColocationStatus> { new SubResourceWithColocationStatus(outVM.Id) }, availabilitySets: new List <SubResourceWithColocationStatus> { new SubResourceWithColocationStatus(outVM.AvailabilitySet.Id) }); ValidateProximityPlacementGroup(expectedProximityPlacementGroup, outProximityPlacementGroup, ppgName); ValidateColocationStatus(expectedInstanceViewStatus, outProximityPlacementGroup.ColocationStatus); }
public virtual Response <ProximityPlacementGroup> CreateOrUpdate(string resourceGroupName, string proximityPlacementGroupName, ProximityPlacementGroup parameters, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ProximityPlacementGroupsOperations.CreateOrUpdate"); scope.Start(); try { return(RestClient.CreateOrUpdate(resourceGroupName, proximityPlacementGroupName, parameters, cancellationToken)); } catch (Exception e) { scope.Failed(e); throw; } }
private async Task TestScaleSetOperationsInternal(string vmSize = null, bool hasManagedDisks = false, bool useVmssExtension = true, bool hasDiffDisks = false, IList <string> zones = null, int?osDiskSizeInGB = null, bool isPpgScenario = false, bool?enableUltraSSD = false, Action <VirtualMachineScaleSet> vmScaleSetCustomizer = null, Action <VirtualMachineScaleSet> vmScaleSetValidator = null, string diskEncryptionSetId = null) { ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true); // Create resource group var rgName = Recording.GenerateAssetName(TestPrefix); var vmssName = Recording.GenerateAssetName("vmss"); string storageAccountName = Recording.GenerateAssetName(TestPrefix); VirtualMachineScaleSet inputVMScaleSet; VirtualMachineScaleSetExtensionProfile extensionProfile = new VirtualMachineScaleSetExtensionProfile() { Extensions = { GetTestVMSSVMExtension(), } }; var storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName); await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartDeleteAsync(rgName, "VMScaleSetDoesNotExist")); string ppgId = null; string ppgName = null; if (isPpgScenario) { ppgName = Recording.GenerateAssetName("ppgtest"); ppgId = await CreateProximityPlacementGroup(rgName, ppgName); } var getTwoVirtualMachineScaleSet = await CreateVMScaleSet_NoAsyncTracking( rgName, vmssName, storageAccountOutput, imageRef, useVmssExtension?extensionProfile : null, (vmScaleSet) => { vmScaleSet.Overprovision = true; if (!String.IsNullOrEmpty(vmSize)) { vmScaleSet.Sku.Name = vmSize; } vmScaleSetCustomizer?.Invoke(vmScaleSet); }, createWithManagedDisks : hasManagedDisks, hasDiffDisks : hasDiffDisks, zones : zones, osDiskSizeInGB : osDiskSizeInGB, ppgId : ppgId, enableUltraSSD : enableUltraSSD, diskEncryptionSetId : diskEncryptionSetId); VirtualMachineScaleSet getResponse = getTwoVirtualMachineScaleSet.Response; inputVMScaleSet = getTwoVirtualMachineScaleSet.Input; if (diskEncryptionSetId != null) { Assert.True(getResponse.VirtualMachineProfile.StorageProfile.OsDisk.ManagedDisk.DiskEncryptionSet != null, "OsDisk.ManagedDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getResponse.VirtualMachineProfile.StorageProfile.OsDisk.ManagedDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "OsDisk.ManagedDisk.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); Assert.AreEqual(1, getResponse.VirtualMachineProfile.StorageProfile.DataDisks.Count); Assert.True(getResponse.VirtualMachineProfile.StorageProfile.DataDisks[0].ManagedDisk.DiskEncryptionSet != null, ".DataDisks.ManagedDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getResponse.VirtualMachineProfile.StorageProfile.DataDisks[0].ManagedDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "DataDisks.ManagedDisk.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); } ValidateVMScaleSet(inputVMScaleSet, getResponse, hasManagedDisks, ppgId: ppgId); var getInstanceViewResponse = await VirtualMachineScaleSetsOperations.GetInstanceViewAsync(rgName, vmssName); Assert.NotNull(getInstanceViewResponse); ValidateVMScaleSetInstanceView(inputVMScaleSet, getInstanceViewResponse); if (isPpgScenario) { ProximityPlacementGroup outProximityPlacementGroup = await ProximityPlacementGroupsOperations.GetAsync(rgName, ppgName); Assert.AreEqual(1, outProximityPlacementGroup.VirtualMachineScaleSets.Count); string expectedVmssReferenceId = Helpers.GetVMScaleSetReferenceId(m_subId, rgName, vmssName); Assert.AreEqual(expectedVmssReferenceId.ToLower(), outProximityPlacementGroup.VirtualMachineScaleSets.First().Id.ToLower()); } var listResponse = await(VirtualMachineScaleSetsOperations.ListAsync(rgName)).ToEnumerableAsync(); ValidateVMScaleSet(inputVMScaleSet, listResponse.FirstOrDefault(x => x.Name == vmssName), hasManagedDisks); var listSkusResponse = await(VirtualMachineScaleSetsOperations.ListSkusAsync(rgName, vmssName)).ToEnumerableAsync(); Assert.NotNull(listSkusResponse); Assert.False(listSkusResponse.Count() == 0); if (zones != null) { var query = "properties/latestModelApplied eq true"; var listVMsResponse = await(VirtualMachineScaleSetVMsOperations.ListAsync(rgName, vmssName, query)).ToEnumerableAsync(); Assert.False(listVMsResponse == null, "VMScaleSetVMs not returned"); Assert.True(listVMsResponse.Count() == inputVMScaleSet.Sku.Capacity); foreach (var vmScaleSetVM in listVMsResponse) { string instanceId = vmScaleSetVM.InstanceId; var getVMResponse = await VirtualMachineScaleSetVMsOperations.GetAsync(rgName, vmssName, instanceId); ValidateVMScaleSetVM(inputVMScaleSet, instanceId, getVMResponse, hasManagedDisks); } } vmScaleSetValidator?.Invoke(getResponse); await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartDeleteAsync(rgName, vmssName)); }
/// <summary> /// Create or update a proximity placement 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='proximityPlacementGroupName'> /// The name of the proximity placement group. /// </param> /// <param name='parameters'> /// Parameters supplied to the Create Proximity Placement Group operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ProximityPlacementGroup> CreateOrUpdateAsync(this IProximityPlacementGroupsOperations operations, string resourceGroupName, string proximityPlacementGroupName, ProximityPlacementGroup parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, proximityPlacementGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
private async Task TestVMScenarioOperationsInternal(string methodName, bool hasManagedDisks = false, IList <string> zones = null, string vmSize = "Standard_A0", string osDiskStorageAccountType = "Standard_LRS", string dataDiskStorageAccountType = "Standard_LRS", bool?writeAcceleratorEnabled = null, bool hasDiffDisks = false, bool callUpdateVM = false, bool isPpgScenario = false, string diskEncryptionSetId = null) { var imageRef = await GetPlatformVMImage(useWindowsImage : true); const string expectedOSName = "Windows Server 2012 R2 Datacenter", expectedOSVersion = "Microsoft Windows NT 6.3.9600.0", expectedComputerName = ComputerName; // Create resource group var rgName = Recording.GenerateAssetName(TestPrefix); string storageAccountName = Recording.GenerateAssetName(TestPrefix); string asName = Recording.GenerateAssetName("as"); string ppgName = null; string expectedPpgReferenceId = null; if (isPpgScenario) { ppgName = Recording.GenerateAssetName("ppgtest"); expectedPpgReferenceId = Helpers.GetProximityPlacementGroupRef(m_subId, rgName, ppgName); } VirtualMachine inputVM; if (!hasManagedDisks) { await CreateStorageAccount(rgName, storageAccountName); } var returnTwoVM = await CreateVM(rgName, asName, storageAccountName, imageRef, hasManagedDisks : hasManagedDisks, hasDiffDisks : hasDiffDisks, vmSize : vmSize, osDiskStorageAccountType : osDiskStorageAccountType, dataDiskStorageAccountType : dataDiskStorageAccountType, writeAcceleratorEnabled : writeAcceleratorEnabled, zones : zones, ppgName : ppgName, diskEncryptionSetId : diskEncryptionSetId); //VirtualMachine outVM = returnTwoVM.Item1; inputVM = returnTwoVM.Input; string inputVMName = returnTwoVM.Name; // Instance view is not completely populated just after VM is provisioned. So we wait here for a few minutes to // allow GA blob to populate. WaitMinutes(5); var getVMWithInstanceViewResponse = (await VirtualMachinesOperations.GetAsync(rgName, inputVMName)).Value; Assert.True(getVMWithInstanceViewResponse != null, "VM in Get"); if (diskEncryptionSetId != null) { Assert.True(getVMWithInstanceViewResponse.StorageProfile.OsDisk.ManagedDisk.DiskEncryptionSet != null, "OsDisk.ManagedDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getVMWithInstanceViewResponse.StorageProfile.OsDisk.ManagedDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "OsDisk.ManagedDisk.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); Assert.AreEqual(1, getVMWithInstanceViewResponse.StorageProfile.DataDisks.Count); Assert.True(getVMWithInstanceViewResponse.StorageProfile.DataDisks[0].ManagedDisk.DiskEncryptionSet != null, ".DataDisks.ManagedDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getVMWithInstanceViewResponse.StorageProfile.DataDisks[0].ManagedDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "DataDisks.ManagedDisk.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); } ValidateVMInstanceView(inputVM, getVMWithInstanceViewResponse, hasManagedDisks, expectedComputerName, expectedOSName, expectedOSVersion); var getVMInstanceViewResponse = await VirtualMachinesOperations.InstanceViewAsync(rgName, inputVMName); Assert.True(getVMInstanceViewResponse != null, "VM in InstanceView"); ValidateVMInstanceView(inputVM, getVMInstanceViewResponse, hasManagedDisks, expectedComputerName, expectedOSName, expectedOSVersion); bool hasUserDefinedAS = zones == null; string expectedVMReferenceId = Helpers.GetVMReferenceId(m_subId, rgName, inputVMName); var listResponse = await(VirtualMachinesOperations.ListAsync(rgName)).ToEnumerableAsync(); ValidateVM(inputVM, listResponse.FirstOrDefault(x => x.Name == inputVMName), expectedVMReferenceId, hasManagedDisks, hasUserDefinedAS, writeAcceleratorEnabled, hasDiffDisks, expectedPpgReferenceId: expectedPpgReferenceId); var listVMSizesResponse = await(VirtualMachinesOperations.ListAvailableSizesAsync(rgName, inputVMName)).ToEnumerableAsync(); Helpers.ValidateVirtualMachineSizeListResponse(listVMSizesResponse, hasAZ: zones != null, writeAcceleratorEnabled: writeAcceleratorEnabled, hasDiffDisks: hasDiffDisks); listVMSizesResponse = await(AvailabilitySetsOperations.ListAvailableSizesAsync(rgName, asName)).ToEnumerableAsync(); Helpers.ValidateVirtualMachineSizeListResponse(listVMSizesResponse, hasAZ: zones != null, writeAcceleratorEnabled: writeAcceleratorEnabled, hasDiffDisks: hasDiffDisks); if (isPpgScenario) { ProximityPlacementGroup outProximityPlacementGroup = await ProximityPlacementGroupsOperations.GetAsync(rgName, ppgName); string expectedAvSetReferenceId = Helpers.GetAvailabilitySetRef(m_subId, rgName, asName); Assert.AreEqual(1, outProximityPlacementGroup.VirtualMachines.Count); Assert.AreEqual(1, outProximityPlacementGroup.AvailabilitySets.Count); Assert.AreEqual(expectedVMReferenceId, outProximityPlacementGroup.VirtualMachines.First().Id); Assert.AreEqual(expectedAvSetReferenceId, outProximityPlacementGroup.AvailabilitySets.First().Id); //Assert.Equal(expectedVMReferenceId, outProximityPlacementGroup.VirtualMachines.First().Id, StringComparer.OrdinalIgnoreCase); //Assert.Equal(expectedAvSetReferenceId, outProximityPlacementGroup.AvailabilitySets.First().Id, StringComparer.OrdinalIgnoreCase); } if (callUpdateVM) { VirtualMachineUpdate updateParams = new VirtualMachineUpdate(); updateParams.Tags.InitializeFrom(inputVM.Tags); string updateKey = "UpdateTag"; updateParams.Tags.Add(updateKey, "UpdateTagValue"); VirtualMachine updateResponse = await WaitForCompletionAsync(await VirtualMachinesOperations.StartUpdateAsync(rgName, inputVMName, updateParams)); Assert.True(updateResponse.Tags.ContainsKey(updateKey)); } }
public virtual async Task <Response <ProximityPlacementGroup> > CreateOrUpdateAsync(string resourceGroupName, string proximityPlacementGroupName, ProximityPlacementGroup parameters, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ProximityPlacementGroupsClient.CreateOrUpdate"); scope.Start(); try { return(await RestClient.CreateOrUpdateAsync(resourceGroupName, proximityPlacementGroupName, parameters, cancellationToken).ConfigureAwait(false)); } catch (Exception e) { scope.Failed(e); throw; } }