Search code examples
c#azurednsbinding

Set custom domain with binding for webapp in Azure C#


I am looking for the way to add custom domain with binding to the webapp in Azure.

I developed something that adds custom domain, but without binding, so its status still without binding (not secured).

Here the code:

var webapp = GetWebApp(request.AzureHostName);

if(webapp is null)
{
    throw new Exception("Failed to get webapp for adding custom domain, will not be done");
}

webapp.App.Update()
   .DefineHostnameBinding()
   .WithThirdPartyDomain(request.DomainName)
   .WithSubDomain(request.SubDomainName)
   .WithDnsRecordType(CustomHostNameDnsRecordType.CName)
   .Attach()
   .Apply();    

I use Microsoft.Azure.Management.Fluent SDK, it is already deprecated.

Is there any option to do it with this SDK, or maybe using a new one, from Azure.ResourceManager

Thank you for your help!


Solution

  • I found the code that can be used, it is not related to client implementation, it is API.

    Please, see:

    C# Azure Management REST API - Bind Certificate to App Service Custom Domain