Thank you for visiting the Rackspace Community
The Community is live! Post new content or topics so our teams can assist.

Please contact your support team if you have a question or need assistance for any Rackspace products, services, or articles.

.Net SDK and DNS Add record

This question is answered.

I cannot get the the following code to work. I get user details returned so I am pretty sure I am being authenticated correctly. I do not think I am getting the CloudDNSProvider returned as most properties come back as nothing. I have tries passing an IIdentityProvider in the 4th param with no luck. I do not get any errors is just doesn't do anything. I cannot find any examples.

Dim identity As RackspaceCloudIdentity = New RackspaceCloudIdentity With {.Username = "xxxx", .APIKey = "correctapikey"}
Dim userDetails = identityProvider.GetUserByName("xxxx", identity)

Dim dnsProvider As CloudDnsProvider = New CloudDnsProvider(identity, Nothing, False, Nothing)
Dim domainID As DomainId = New DomainId("ourdomain.com")

Dim dnsEntry As New List(Of DnsDomainRecordConfiguration)
dnsEntry.Add(New DnsDomainRecordConfiguration(DnsRecordType.A, "test", "192.168.0.200", TimeSpan.FromMinutes(20), "", Nothing))

Dim dnsReturnValue = dnsProvider.AddRecordsAsync(domainID, dnsEntry, net.openstack.Core.AsyncCompletionOption.RequestCompleted, CancellationToken.None, Nothing)

Verified Answer
All Replies
  • Hi Joel,

    Do you happen to have the message from the exception as well? I notice the ContentType is text/plain so the content of the response might not be included in the exception message.

    For logging requests and responses in the integration tests, I use the following code. The result is a complete trace of all requests and the complete responses (with headers), even if the response is not valid JSON.


    ·         CreateProvider and TestCloudDnsProvider.
    https://github.com/openstacknetsdk/openstack.net/blob/3c6660e1145b676c102f873b67f6acd8f15fb9d2/src/testing/integration/Providers/Rackspace/UserDnsTests.cs#L816-L849

    ·         The above class relies on the helper class TestHelpers which you can find here:
    https://github.com/openstacknetsdk/openstack.net/blob/master/src/testing/integration/Providers/Rackspace/TestHelpers.cs

    The above code writes output using Console.Error.WriteLine, but you could update it to use Trace.WriteLine or another method that would be usable for debugging your Windows Forms application.


    ***Looks Like this was issue was solved via an email with sam on the SDK team** however I thought this might be helpful to others ***

  • Yes, the Rackspace Team helped me to get DNS AddRecord working. I am now working on delete and update which are different and not solved yet. Here is the working code for adding a record in vb.net. I will post delete and update when I get them working:

    Dim statusMsg As String = ""
    Dim cloudId As CloudIdentity = New CloudIdentity With {.Username = "yourunhere", .APIKey = "yourapikeyhere"}
    Dim identityProvider As IIdentityProvider = New CloudIdentityProvider(cloudId)
    Dim ua As UserAccess = identityProvider.Authenticate(cloudId)
    Dim dnsProvider As IDnsService = New CloudDnsProvider(cloudId, Nothing, False, Nothing)
    Dim domainID As New DomainId(domain) ' domain id not string name, get by hovering over your doamin in control panel
    Dim dnsEntry As New List(Of DnsDomainRecordConfiguration)()
    dnsEntry.Add(New DnsDomainRecordConfiguration(DnsRecordType.A, "test.yourdomain.com", "192.168.0.1", TimeSpan.FromMinutes(20), "", Nothing)) ' make sure to us FQDN in second param
    Dim dnsReturnValue = dnsProvider.AddRecordsAsync(domainID, dnsEntry, AsyncCompletionOption.RequestCompleted, CancellationToken.None, Nothing).Result

  • For others use, here is DeleteRecord. Still fighting update.

    Dim statusMsg As String = ""
    Dim cloudId As CloudIdentity = New CloudIdentity With {.Username = "yourunhere", .APIKey = "yourapikeyhere"}
    Dim identityProvider As IIdentityProvider = New CloudIdentityProvider(cloudId)
    Dim ua As UserAccess = identityProvider.Authenticate(cloudId)
    Dim dnsProvider As IDnsService = New CloudDnsProvider(cloudId, Nothing, False, Nothing)
    Dim domainID As New DomainId(domain) ' domain id not string name, get by hovering over your domaiin in control panel
    Dim recordList As Tuple(Of net.openstack.Core.Collections.ReadOnlyCollectionPage(Of DnsRecord), Integer?) = dnsProvider.ListRecordsAsync(domainID, DnsRecordType.A, "fqdnhere", "", Nothing, Nothing, CancellationToken.None).Result ' get record id for delete function
    Dim recordID As New RecordId(recordList.Item1(0).Id.Value)
    Dim recordIDs As New List(Of RecordId)()
    recordIDs.Add(recordID)
    Dim dnsReturnValue = dnsProvider.RemoveRecordsAsync(domainID, recordIDs, AsyncCompletionOption.RequestCompleted, CancellationToken.None, Nothing).Result

  • Here is UpdateRecord. Not sure if it is exactly right but it works.

    Dim cloudId As CloudIdentity = New CloudIdentity With {.Username = "yourunhere", .APIKey = "yourapikeyhere"}
    Dim identityProvider As IIdentityProvider = New CloudIdentityProvider(cloudId)
    Dim ua As UserAccess = identityProvider.Authenticate(cloudId)
    Dim dnsProvider As IDnsService = New CloudDnsProvider(cloudId, Nothing, False, Nothing)
    Dim domainID As New DomainId(domain) ' domain id not string name, get by hovering over your domaiin in control panelDim recordList As Tuple(Of net.openstack.Core.Collections.ReadOnlyCollectionPage(Of DnsRecord), Integer?) = dnsProvider.ListRecordsAsync(domainID, DnsRecordType.A, aRecord, "", Nothing, Nothing, CancellationToken.None).Result
    Dim thisRecord As DnsRecord = recordList.Item1(0)
    Dim dnsEntry As New List(Of DnsDomainRecordUpdateConfiguration)()
    dnsEntry.Add(New DnsDomainRecordUpdateConfiguration(thisRecord, "yourfqdnhere", aIP, TimeSpan.FromMinutes(20), "", Nothing))
    Dim dnsReturnValue = dnsProvider.UpdateRecordsAsync(domainID, dnsEntry, AsyncCompletionOption.RequestCompleted, CancellationToken.None, Nothing).Result