public void CrudZoneSetsTheCurrentAndMaxRecordSetNumbersInResponse() { using (UndoContext context = UndoContext.Current) { context.Start(); DnsManagementClient dnsClient = ResourceGroupHelper.GetDnsClient(); string zoneName = TestUtilities.GenerateName("hydratestdnszone"); string location = ResourceGroupHelper.GetResourceLocation(ResourceGroupHelper.GetResourcesClient(), "microsoft.network/dnszones"); ResourceGroupExtended resourceGroup = ResourceGroupHelper.CreateResourceGroup(); // Create the zone clean ZoneCreateOrUpdateResponse createResponse = dnsClient.Zones.CreateOrUpdate( resourceGroup.Name, zoneName, new ZoneCreateOrUpdateParameters { Zone = new Microsoft.Azure.Management.Dns.Models.Zone { Location = location, Name = zoneName, Properties = new Microsoft.Azure.Management.Dns.Models.ZoneProperties { MaxNumberOfRecordSets = 42, // Test that specifying this value does not break Create (it must be ignored on server side). NumberOfRecordSets = 65, // Test that specifying this value does not break Create (it must be ignored on server side). } } }); // Verify RecordSet numbers in the response. Assert.Equal(HttpStatusCode.Created, createResponse.StatusCode); // Retrieve the zone after create ZoneGetResponse getResponse = dnsClient.Zones.Get(resourceGroup.Name, zoneName); // Verify RecordSet numbers in the response. Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode); Assert.True(getResponse.Zone.Properties.NumberOfRecordSets == 2); Zone retrievedZone = getResponse.Zone; retrievedZone.Tags = new Dictionary <string, string> { { "tag1", "value1" } }; retrievedZone.Properties.NumberOfRecordSets = null; retrievedZone.Properties.MaxNumberOfRecordSets = null; // Update the zone ZoneCreateOrUpdateResponse updateResponse = dnsClient.Zones.CreateOrUpdate(resourceGroup.Name, zoneName, new ZoneCreateOrUpdateParameters { Zone = retrievedZone }); // Verify RecordSet numbers in the response. Assert.Equal(HttpStatusCode.OK, updateResponse.StatusCode); // Delete the zone AzureOperationResponse deleteResponse = dnsClient.Zones.Delete(resourceGroup.Name, zoneName, new ZoneDeleteParameters()); Assert.Equal(HttpStatusCode.OK, deleteResponse.StatusCode); } }
public DnsZone GetDnsZone(string name, string resourceGroupName) { ZoneGetResponse getResponse = this.DnsManagementClient.Zones.Get(resourceGroupName, name); return(new DnsZone { Name = getResponse.Zone.Name, ResourceGroupName = resourceGroupName, Etag = getResponse.Zone.ETag, Tags = TagsConversionHelper.CreateTagHashtable(getResponse.Zone.Tags), }); }