Exemple #1
0
        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
        }
Exemple #2
0
        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
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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
        }