Exemple #1
0
        public void UpdateZonePreconditionFailed()
        {
            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();
                ZoneCreateOrUpdateResponse createresponse = ResourceGroupHelper.CreateZone(dnsClient, zoneName, location, resourceGroup);

                ZoneCreateOrUpdateParameters updateParameters = new ZoneCreateOrUpdateParameters {
                    Zone = createresponse.Zone
                };
                updateParameters.Zone.ETag = "somegibberish";

                // expect Precondition Failed 412
                TestHelpers.AssertThrows <CloudException>(
                    () => dnsClient.Zones.CreateOrUpdate(resourceGroup.Name, zoneName, updateParameters),
                    ex => ex.Error.Code == "PreconditionFailed");

                // expect Precondition Failed 412
                TestHelpers.AssertThrows <CloudException>(
                    () => dnsClient.Zones.Delete(resourceGroup.Name, zoneName, new ZoneDeleteParameters {
                    IfMatch = "somemoregib"
                }),
                    ex => ex.Error.Code == "PreconditionFailed");

                dnsClient.Zones.Delete(resourceGroup.Name, zoneName, new ZoneDeleteParameters());
            }
        }
Exemple #2
0
        public void UpdateZonePreconditionFailed()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                DnsManagementClient dnsClient = ResourceGroupHelper.GetDnsClient();

                string zoneName = TestUtilities.GenerateName("hydratestdnszone.com");
                string location = ResourceGroupHelper.GetResourceLocation(ResourceGroupHelper.GetResourcesClient(), "microsoft.network/dnszones");
                ResourceGroupExtended      resourceGroup  = ResourceGroupHelper.CreateResourceGroup();
                ZoneCreateOrUpdateResponse createresponse = ResourceGroupHelper.CreateZone(dnsClient, zoneName, location, resourceGroup);

                ZoneCreateOrUpdateParameters updateParameters = new ZoneCreateOrUpdateParameters {
                    Zone = createresponse.Zone
                };
                updateParameters.Zone.ETag = "somegibberish";

                // expect Precondition Failed 412
                TestHelpers.AssertThrows <CloudException>(
                    () => dnsClient.Zones.CreateOrUpdate(resourceGroup.Name, zoneName, ifMatch: null, ifNoneMatch: null, parameters: updateParameters),
                    ex => ex.Error.Code == "PreconditionFailed");

                var result = dnsClient.Zones.Delete(resourceGroup.Name, zoneName, ifMatch: null, ifNoneMatch: null);
                Assert.Equal(HttpStatusCode.OK, result.StatusCode);

                result = dnsClient.Zones.Delete(resourceGroup.Name, "hiya.com", ifMatch: null, ifNoneMatch: null);
                Assert.Equal(HttpStatusCode.NoContent, result.StatusCode);
            }
        }
        protected async void AddZone()
        {
            InputDialog input = new InputDialog("Enter zone name", "Enter the name of the DNS zone to add", "");

            if (ActiveResourceGroup != null && input.ShowDialog() == true)
            {
                ZoneCreateOrUpdateParameters p = new ZoneCreateOrUpdateParameters();
                p.Zone            = new Zone("global");
                p.Zone.Properties = new ZoneProperties();
                try
                {
                    ZoneCreateOrUpdateResponse responseCreateZone = await _dnsManagementClient.Zones.CreateOrUpdateAsync(ActiveResourceGroup.Name, input.Value, p, null, null);

                    ReloadZones();
                } catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    MessageBox.Show("Failed to add zone name!");
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// Creates a DNS zone within a resource group.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Management.Dns.IZoneOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='zoneName'>
 /// Required. The name of the zone without a terminating dot.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the CreateOrUpdate operation.
 /// </param>
 /// <param name='ifMatch'>
 /// Optional. The etag of Zone.
 /// </param>
 /// <param name='ifNoneMatch'>
 /// Optional. Defines the If-None-Match condition. Set to '*' to force
 /// Create-If-Not-Exist. Other values will be ignored.
 /// </param>
 /// <returns>
 /// The response to a Zone CreateOrUpdate operation.
 /// </returns>
 public static Task <ZoneCreateOrUpdateResponse> CreateOrUpdateAsync(this IZoneOperations operations, string resourceGroupName, string zoneName, ZoneCreateOrUpdateParameters parameters, string ifMatch, string ifNoneMatch)
 {
     return(operations.CreateOrUpdateAsync(resourceGroupName, zoneName, parameters, ifMatch, ifNoneMatch, CancellationToken.None));
 }
Exemple #5
0
 /// <summary>
 /// Creates a DNS zone within a resource group.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.Azure.Management.Dns.IZoneOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='zoneName'>
 /// Required. The name of the zone without a terminating dot.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the CreateOrUpdate operation.
 /// </param>
 /// <param name='ifMatch'>
 /// Optional. The etag of Zone.
 /// </param>
 /// <param name='ifNoneMatch'>
 /// Optional. Defines the If-None-Match condition. Set to '*' to force
 /// Create-If-Not-Exist. Other values will be ignored.
 /// </param>
 /// <returns>
 /// The response to a Zone CreateOrUpdate operation.
 /// </returns>
 public static ZoneCreateOrUpdateResponse CreateOrUpdate(this IZoneOperations operations, string resourceGroupName, string zoneName, ZoneCreateOrUpdateParameters parameters, string ifMatch, string ifNoneMatch)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IZoneOperations)s).CreateOrUpdateAsync(resourceGroupName, zoneName, parameters, ifMatch, ifNoneMatch);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }