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 }
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 }
public async Task <DnsZoneResource> CreateADnsZone(string dnsZoneName, ResourceGroupResource rg) { DnsZoneCollection collection = rg.GetDnsZones(); DnsZoneData data = new DnsZoneData("Global") { }; var dns = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dnsZoneName, data); return(dns.Value); }
public async Task TearDown() { var list = await _resourceGroup.GetDnsZones().GetAllAsync().ToEnumerableAsync(); foreach (var item in list) { await item.DeleteAsync(WaitUntil.Completed); } }
public async Task DeleteDnsZone() { #region Snippet:Managing_DnsZones_DeleteDnsZone 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); // Now we get the DnsZone collection from the resource group DnsZoneCollection dnsZoneCollection = resourceGroup.GetDnsZones(); string dnsZoneName = "sample.com"; DnsZoneResource dnsZone = await dnsZoneCollection.GetAsync(dnsZoneName); await dnsZone.DeleteAsync(WaitUntil.Completed); #endregion Snippet:Managing_DnsZones_DeleteDnsZone }
public async Task ListDnsZones() { #region Snippet:Managing_DnsZones_ListAllDnsZones 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); // Now we get the DnsZone collection from the resource group DnsZoneCollection dnsZoneCollection = resourceGroup.GetDnsZones(); // With ListAsync(), we can get a list of the DnsZones AsyncPageable <DnsZoneResource> response = dnsZoneCollection.GetAllAsync(); await foreach (DnsZoneResource dnsZone in response) { Console.WriteLine(dnsZone.Data.Name); } #endregion Snippet:Managing_DnsZones_ListAllDnsZones }
public async Task CreateADnsZone() { #region Snippet:Managing_DnsZones_CreateADnsZones 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); // Now we get the DnsZone collection from the resource group DnsZoneCollection dnsZoneCollection = resourceGroup.GetDnsZones(); // Use the same location as the resource group string dnsZoneName = "sample.com"; DnsZoneData data = new DnsZoneData("Global") { }; ArmOperation <DnsZoneResource> lro = await dnsZoneCollection.CreateOrUpdateAsync(WaitUntil.Completed, dnsZoneName, data); DnsZoneResource dnsZone = lro.Value; #endregion Snippet:Managing_DnsZones_CreateADnsZones }
public static Response <DnsZoneResource> GetDnsZone(this ResourceGroupResource resourceGroupResource, string zoneName, CancellationToken cancellationToken = default) { return(resourceGroupResource.GetDnsZones().Get(zoneName, cancellationToken)); }
public static async Task <Response <DnsZoneResource> > GetDnsZoneAsync(this ResourceGroupResource resourceGroupResource, string zoneName, CancellationToken cancellationToken = default) { return(await resourceGroupResource.GetDnsZones().GetAsync(zoneName, cancellationToken).ConfigureAwait(false)); }