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 static DnsZoneResource GetDnsZoneResource(this ArmClient client, ResourceIdentifier id) { return(client.GetResourceClient <DnsZoneResource>(() => { DnsZoneResource.ValidateResourceId(id); return new DnsZoneResource(client, id); } )); }
public async Task Exist() { string dnsZoneName = $"{SessionRecording.GenerateAssetName("sample")}.com"; _dnsZone = await CreateADnsZone(dnsZoneName, _resourceGroup); bool result = await _dnsZone.GetRecordSetSoas().ExistsAsync("@"); Assert.IsTrue(result); }
public async Task GetAll() { string dnsZoneName = $"{SessionRecording.GenerateAssetName("sample")}.com"; _dnsZone = await CreateADnsZone(dnsZoneName, _resourceGroup); var list = await _dnsZone.GetRecordSetSoas().GetAllAsync().ToEnumerableAsync(); Assert.IsNotNull(list); Assert.AreEqual("@", list.FirstOrDefault().Data.Name); }
public async Task Get() { string dnsZoneName = $"{SessionRecording.GenerateAssetName("sample")}.com"; _dnsZone = await CreateADnsZone(dnsZoneName, _resourceGroup); var recordSetSoaResource = await _dnsZone.GetRecordSetSoas().GetAsync("@"); Assert.IsNotNull(recordSetSoaResource); Assert.AreEqual("@", recordSetSoaResource.Value.Data.Name); Assert.AreEqual("Succeeded", recordSetSoaResource.Value.Data.ProvisioningState); Assert.AreEqual("dnszones/SOA", recordSetSoaResource.Value.Data.ResourceType.Type); }
public async Task Exist() { string dnsZoneName = $"{SessionRecording.GenerateAssetName("sample")}.com"; _dnsZone = await CreateADnsZone(dnsZoneName, _resourceGroup); var collection = _dnsZone.GetRecordSetNs(); await collection.CreateOrUpdateAsync(WaitUntil.Completed, _recordSetName, new NsRecordSetData() { }); Assert.IsTrue(collection.Exists(_recordSetName)); }
public async Task Create() { string dnsZoneName = $"{SessionRecording.GenerateAssetName("sample")}.com"; _dnsZone = await CreateADnsZone(dnsZoneName, _resourceGroup); var collection = _dnsZone.GetRecordSetNs(); var recordSetNsResource = await collection.CreateOrUpdateAsync(WaitUntil.Completed, _recordSetName, new NsRecordSetData() { }); Assert.IsNotNull(recordSetNsResource); Assert.AreEqual(_recordSetName, recordSetNsResource.Value.Data.Name); Assert.AreEqual("Succeeded", recordSetNsResource.Value.Data.ProvisioningState); Assert.AreEqual("dnszones/NS", recordSetNsResource.Value.Data.ResourceType.Type); }
public async Task GetAll() { string dnsZoneName = $"{SessionRecording.GenerateAssetName("sample")}.com"; _dnsZone = await CreateADnsZone(dnsZoneName, _resourceGroup); var collection = _dnsZone.GetRecordSetSrvs(); string name = "srv"; await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, new SrvRecordSetData() { }); var list = await collection.GetAllAsync().ToEnumerableAsync(); Assert.IsNotNull(list); Assert.AreEqual(name, list.FirstOrDefault().Data.Name); }
public async Task Delete() { string dnsZoneName = $"{SessionRecording.GenerateAssetName("sample")}.com"; _dnsZone = await CreateADnsZone(dnsZoneName, _resourceGroup); var collection = _dnsZone.GetRecordSetSrvs(); string name = "srv"; var recordSetSrvResource = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, new SrvRecordSetData() { }); Assert.IsTrue(collection.Exists(name)); await recordSetSrvResource.Value.DeleteAsync(WaitUntil.Completed); Assert.IsFalse(collection.Exists(name)); }
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 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 }