0

How can we get the domain name on which the Azure vm is created using c#.. just would like to know if there is any api...

tried

ComputeManagementClient.Deployments.GetBySlot

but that returns DeploymentGetResponse which doesnt have domain info

shiv455
  • 7,384
  • 19
  • 54
  • 93
  • Are you trying to find out xyz.cloudapp.net or yourdomain.com when you say domain name? – Gaurav Mantri Sep 08 '14 at 18:43
  • @Gaurav yourdomain.com – shiv455 Sep 08 '14 at 18:46
  • for a given azureVm name i would like to get the domainname on which the vm is created – shiv455 Sep 08 '14 at 18:48
  • 1
    AFAIK, this is not possible as you map the custom domain name (i.e. yourdomain.com) through CNAME mapping in your domain name provider (e.g. GoDadday.com etc.). Azure has no knowledge whatsoever about what you do there. – Gaurav Mantri Sep 08 '14 at 18:50
  • actually i was asking this cos i want to delete VM from AD using System.DirectoryServices.AccountManagement and there i need to pass the domain name to PrincipalContext object...so do i need to configure domain name from webconfig/appconfig?? please suggest – shiv455 Sep 08 '14 at 18:59
  • I'm sorry but I have no idea about that. Let's hope somebody else pitches in. – Gaurav Mantri Sep 08 '14 at 19:07

1 Answers1

0

Now that you have described in little more details what you are trying to achieve, you need the domain under which the VM is joined but not under which the VM is deployed. Because your AD certainly does not have control over *.cloudapp.net. And your mapped public domain may be different from your AD Domain.

Following this SO question, you can get the Domain to which the VM is joined executing the following code on the VM itself:

System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName;
Community
  • 1
  • 1
astaykov
  • 30,768
  • 3
  • 70
  • 86