Darkestlyrics
Darkestlyrics

Reputation: 310

Creating sub domains on Azure Programmatically in .Net Core

I'm trying to create sub-domains within Azure in a .Net Core app, basically just want to get the connection at this stage and then go from there.

I've created a simple .net core console app just to POC this.

I have checked this question Add custom domain names to web apps using REST API However the package referenced seems to be targeting the .net framework.

Is there a .net core specific library? Tried googling around and everything points me back to the WebSiteManagementClient class.

Am I being an idiot?

Upvotes: 1

Views: 663

Answers (1)

Alex
Alex

Reputation: 18546

Look into the Microsoft.Azure.Management.* packages. They usually support .NET Standard, so you can use them in .NET Core.

I am not quite sure where you want to create the sub-domain, but since you mention WebApps, I assume you mean those.

You can check out Microsoft.Azure.Management.AppService.Fluent

https://github.com/Azure/azure-libraries-for-net/blob/b5b74deab165119cfe8dfe0e3b61b18964b3d477/src/ResourceManagement/AppService/Domain/HostNameBinding/Definition/IDefinition.cs

namespace Microsoft.Azure.Management.AppService.Fluent.HostNameBinding.Definition
{
    using Microsoft.Azure.Management.AppService.Fluent;
    using Microsoft.Azure.Management.ResourceManager.Fluent.Core.ChildResource.Definition;
    using Microsoft.Azure.Management.AppService.Fluent.Models;

    /// <summary>
    /// The stage of a hostname binding definition allowing domain to be specified.
    /// </summary>
    /// <typeparam name="ParentT">The stage of the parent definition to return to after attaching this definition.</typeparam>
    public interface IWithDomain<ParentT> 
    {
        /// <summary>
        /// Binds to a 3rd party domain.
        /// </summary>
        /// <param name="domain">The 3rd party domain name.</param>
        /// <return>The next stage of the definition.</return>
        Microsoft.Azure.Management.AppService.Fluent.HostNameBinding.Definition.IWithSubDomain<ParentT> WithThirdPartyDomain(string domain);

        /// <summary>
        /// Binds to a domain purchased from Azure.
        /// </summary>
        /// <param name="domain">The domain purchased from Azure.</param>
        /// <return>The next stage of the definition.</return>
        Microsoft.Azure.Management.AppService.Fluent.HostNameBinding.Definition.IWithSubDomain<ParentT> WithAzureManagedDomain(IAppServiceDomain domain);
    }


    /// <summary>
    /// The stage of a hostname binding definition allowing sub-domain to be specified.
    /// </summary>
    /// <typeparam name="ParentT">The stage of the parent definition to return to after attaching this definition.</typeparam>
    public interface IWithSubDomain<ParentT> 
    {
        /// <summary>
        /// Specifies the sub-domain to bind to.
        /// </summary>
        /// <param name="subDomain">The sub-domain name excluding the top level domain, e.g., "www".</param>
        /// <return>The next stage of the definition.</return>
        Microsoft.Azure.Management.AppService.Fluent.HostNameBinding.Definition.IWithHostNameDnsRecordType<ParentT> WithSubDomain(string subDomain);
    }

Upvotes: 1

Related Questions