0
             var recordSetParams = new RecordSet();
                recordSetParams.TTL = 3600;
                recordSetParams.TxtRecords = new List<TxtRecord>();
                var strings = new List<string>();
                var records = new List<string>() { "record1", "record2", "record3" };
                foreach (var record in records)
                {
                    strings.Add(record);
                }

                recordSetParams.TxtRecords.Add(new TxtRecord(strings));

                await DnsClient.RecordSets.CreateOrUpdateAsync(ResourceGroupName, zone.Name, Name,RecordType.TXT, recordSetParams);

TXT record created but on same line

Is there any way so that record can be added on multiple line.

[Ref] : https://learn.microsoft.com/en-us/azure/dns/dns-sdk

Expected result enter image description here

1 Answers1

0

I have reproduced according to your requirement. Below is the code that works for me.

using System;
using System.Collections.Generic;
using Azure.Identity;
using ConsoleApp8;
using Microsoft.Azure.Management.Dns.Fluent.Models;
using Microsoft.Azure.Management.Dns.Fluent;


namespace ConsoleApp9
{
    class Program
    {
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            string subscriptionId = "<your-subscription-id>";
            string resourceGroupName = "<your-resource-group-name>";
            string zoneName = "<your-zone-name>";
            string recordSetName = "<your-record-set-name>";

            var credential = new DefaultAzureCredential();
            var dnsClient = new DnsManagementClient(credential);

            var recordSetParams = new RecordSet();
            recordSetParams.TTL = 3600;

            var records = new List<string>() { "Recordvalue", "Recordvalue1", "Recordvalue2" };
            recordSetParams.TxtRecords = new List<TxtRecord>
        {
            new TxtRecord(records)
        };

            await dnsClient.RecordSets.CreateOrUpdateAsync(resourceGroupName, zoneName, recordSetName, RecordType.TXT, recordSetParams);

            Console.WriteLine("TXT records added successfully.");
        }
    }
}

Here are the packages install in my application.

Output : enter image description here

  • Here are the multiple TXT records in Azure DNS Zone. enter image description here
Suresh Chikkam
  • 623
  • 2
  • 2
  • 6
  • https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors/285557#285557 – John Hanley Jul 29 '23 at 00:16