%3CLINGO-SUB%20id%3D%22lingo-sub-1646823%22%20slang%3D%22en-US%22%3EAPEX%20Domains%20to%20Azure%20Functions%20in%203%20Ways%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1646823%22%20slang%3D%22en-US%22%3E%3CP%3EThroughout%20this%20series%2C%20I'm%20going%20to%20show%20how%20an%20Azure%20Functions%20instance%20can%20map%20APEX%20domains%2C%20add%20an%20SSL%20certificate%20and%20update%20its%20public%20inbound%20IP%20address%20to%20DNS.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3E%3CEM%3EAPEX%20Domains%20to%20Azure%20Functions%20in%203%20Ways%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3ELet's%20Encrypt%20SSL%20Certificate%20to%20Azure%20Functions%3C%2FLI%3E%0A%3CLI%3EUpdating%20DNS%20A%20Record%20for%20Azure%20Functions%20Automatically%3C%2FLI%3E%0A%3CLI%3EDeploying%20Azure%20Functions%20via%20GitHub%20Actions%20without%20Publish%20Profile%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet's%20say%20there%20is%20an%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-functions%2Ffunctions-overview%3FWT.mc_id%3Dappsonazure-techcommunity-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Functions%3C%2FA%3E%20instance.%20One%20of%20your%20customers%20wants%20to%20add%20a%20custom%20domain%20to%20the%20Function%20app.%20As%20long%20as%20the%20custom%20domain%20is%20a%20sub-domain%20type%20like%3CCODE%3Eapi.contoso.com%3C%2FCODE%3E%2C%20it%20shouldn't%20be%20an%20issue%20because%20CNAME%20mapping%20is%20supported%20out-of-the-box.%20But%20what%20if%20the%20customer%20wants%20to%20add%20an%20APEX%20domain%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3EBoth%20APEX%20domain%20and%20root%20domain%20point%20to%20the%20same%20thing%20like%3CCODE%3Econtoso.com%3C%2FCODE%3E.%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2020%2F10%2F3-ways-mapping-apex-domains-to-azure-functions-01-en.png%22%20border%3D%220%22%20alt%3D%22%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAdding%20the%20root%20domain%20through%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Ffeatures%2Fazure-portal%2F%3FWT.mc_id%3Dappsonazure-techcommunity-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Portal%3C%2FA%3E%20can't%20be%20accomplished%20with%20the%20message%20above.%20To%20add%20the%20APEX%20domain%20to%20Azure%20Functions%20instance%2C%20it%20requires%20an%20A%20record%20that%20needs%20a%20public%20IP%20address.%20But%20Azure%20Functions%20instance%20doesn't%20support%20it%20via%20the%20portal.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EShould%20we%20give%20it%20up%20now%3F%20Well%2C%20not%20really.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2020%2F10%2F3-ways-mapping-apex-domains-to-azure-functions-02-en.jpg%22%20border%3D%220%22%20alt%3D%22%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20always%2C%20there's%20a%20way%20to%20get%20around.%20Throughout%20this%20post%2C%20I'm%20going%20to%20show%20how%20to%20map%20the%20APEX%20domain%20to%20an%20Azure%20Functions%20instance%20in%20three%20different%20ways.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1238875218%22%20id%3D%22toc-hId--1238875218%22%3EVerifying%20Domain%20Ownership%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%20of%20all%2C%20you%20need%20to%20verify%20the%20domain%20ownership%20at%20the%3CCODE%3ECustom%20Domains%3C%2FCODE%3Eblade%20of%20the%20Function%20app%20instance.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2020%2F10%2F3-ways-mapping-apex-domains-to-azure-functions-03-en.png%22%20border%3D%220%22%20alt%3D%22%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EGet%20the%3CCODE%3ECustom%20Domain%20Verification%20ID%3C%2FCODE%3Eat%20the%20picture%20above.%3C%2FLI%3E%0A%3CLI%3EAdd%20the%20TXT%20record%2C%3CCODE%3Easuid.contoso.com%3C%2FCODE%3E%2C%20to%20your%20DNS%20server.%3C%2FLI%3E%0A%3CLI%3EAdd%20the%20A%20record%20with%20the%20IP%20address%20to%20your%20DNS%20server.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20verification%20process%20can%20be%20done%20via%20the%20portal.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3EIf%20you%20want%20to%20run%20the%20verification%20with%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2Fwhat-is-azure-cli%3FWT.mc_id%3Dappsonazure-techcommunity-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20CLI%3C%2FA%3E%2C%20please%20have%20a%20look%20at%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazure-cli%2Fissues%2F14142%23issuecomment-676539150%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Elink%3C%2FA%3E.%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2020%2F10%2F3-ways-mapping-apex-domains-to-azure-functions-04-en.png%22%20border%3D%220%22%20alt%3D%22%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%2C%20you've%20verified%20the%20domain%20ownership.%20But%20you%20haven't%20still%20yet%20made%20the%20APEX%20domain%20mapping.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1248637615%22%20id%3D%22toc-hId-1248637615%22%3E1.%20Through%20Azure%20PowerShell%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20can't%20make%20it%20through%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Ffeatures%2Fazure-portal%2F%3FWT.mc_id%3Dappsonazure-techcommunity-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Portal%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpowershell%2Fazure%2Fnew-azureps-module-az%3FWT.mc_id%3Dappsonazure-techcommunity-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20PowerShell%3C%2FA%3E%20will%20be%20one%20alternative.%20Use%20the%3CCODE%3ESet-AzWebApp%3C%2FCODE%3Ecmdlet%20to%20map%20your%20APEX%20domain.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%24resourceGroupName%20%3D%20%22%5BRESOURCE_GROUP_NAME%5D%22%0A%20%20%20%20%24functionAppName%20%3D%20%22%5BFUNCTION_APP_NAME%5D%22%0A%20%20%20%20%24domainName%20%3D%20%22contoso.com%22%0A%20%20%20%20Set-AzWebApp%20%60%0A%20%20%20%20%20%20%20%20-ResourceGroupName%20%24resourceGroupName%20%60%0A%20%20%20%20%20%20%20%20-Name%20%24functionAppName%20%60%0A%20%20%20%20%20%20%20%20-HostNames%20%40(%20%24domainName%2C%20%22%24functionAppName.azurewebsites.net%22%20)%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20you%20use%20Azure%20PowerShell%2C%20you%20MUST%20make%20sure%20one%20thing.%20The%3CCODE%3E-HostNames%3C%2FCODE%3Eparameter%20specified%20above%20MUST%20include%20the%20existing%20domain%20names%20(line%20%237).%20Otherwise%2C%20all%20existing%20domains%20will%20be%20removed%2C%20and%20you%20will%20get%20the%20warning%20like%20below%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2020%2F10%2F3-ways-mapping-apex-domains-to-azure-functions-05-en.png%22%20border%3D%220%22%20alt%3D%22%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20add%20all%20custom%20domains%20including%20the%20default%20domain%20name%20like%3CCODE%3E*.azurewebsites.net%3C%2FCODE%3E%2C%20you%20will%20be%20able%20to%20see%20the%20screen%20below%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2020%2F10%2F3-ways-mapping-apex-domains-to-azure-functions-06-en.png%22%20border%3D%220%22%20alt%3D%22%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--558816848%22%20id%3D%22toc-hId--558816848%22%3E2.%20Through%20Azure%20CLI%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20prefer%20to%20using%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2Fwhat-is-azure-cli%3FWT.mc_id%3Dappsonazure-techcommunity-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20CLI%3C%2FA%3E%2C%20use%20the%20command%2C%3CCODE%3Eaz%20functionapp%20config%20hostname%20add%3C%2FCODE%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20az%20functionapp%20config%20hostname%20add%20%5C%0A%20%20%20%20%20%20%20%20-g%20%5BRESOURCE_GROUP_NAME%5D%20%5C%0A%20%20%20%20%20%20%20%20-n%20%5BFUNCTIONAPP_NAME%5D%20%5C%0A%20%20%20%20%20%20%20%20--hostname%20%22contoso.com%22%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUnlike%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpowershell%2Fazure%2Fnew-azureps-module-az%3FWT.mc_id%3Dappsonazure-techcommunity-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20PowerShell%3C%2FA%3E%2C%20you%20can%20add%20one%20hostname%20at%20a%20time%20and%20won't%20lose%20the%20ones%20already%20added.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1928695985%22%20id%3D%22toc-hId-1928695985%22%3E3.%20Through%20ARM%20Template%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20use%20ARM%20Template%20instead%20of%20command-line%20commands.%20Here's%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fazure%2Fbicep%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ebicep%3C%2FA%3E%20code%20for%20it%20(line%20%235-8).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20resource%20fncapp%20'Microsoft.Web%2Fsites%402020-06-01'%20%3D%20%7B%0A%20%20%20%20%20%20%20%20name%3A%20functionApp.name%0A%20%20%20%20%20%20%20%20...%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20resource%20fncappHostname%20'Microsoft.Web%2Fsites%2FhostNameBindings%402020-06-01'%20%3D%20%7B%0A%20%20%20%20%20%20%20%20name%3A%20'%24%7Bfncapp.name%7D%2Fcontoso.com'%0A%20%20%20%20%20%20%20%20location%3A%20fncapp.location%0A%20%20%20%20%7D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20the%20bicep%20file%20is%20compiled%20to%20ARM%20Template%2C%20it%20looks%20like%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%7B%0A%20%20%20%20%20%20...%0A%20%20%20%20%20%20%22resources%22%3A%20%5B%0A%20%20%20%20%20%20%20%20...%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22Microsoft.Web%2Fsites%2FhostNameBindings%22%2C%0A%20%20%20%20%20%20%20%20%20%20%22apiVersion%22%3A%20%222020-06-01%22%2C%0A%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22%5Bformat('%7B0%7D%2F%7B1%7D'%2C%20variables('functionApp').name%2C%20'contoso.com')%5D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%22location%22%3A%20%22%5Bvariables('functionApp').location%5D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%22dependsOn%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%5BresourceId('Microsoft.Web%2Fsites'%2C%20variables('functionApp').name)%5D%22%0A%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20...%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20...%0A%20%20%20%20%7D%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CHR%20%2F%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20far%2C%20we've%20used%20three%20different%20ways%20to%20map%20an%20APEX%20domain%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-functions%2Ffunctions-overview%3FWT.mc_id%3Dappsonazure-techcommunity-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Functions%3C%2FA%3E%20instance.%20Generally%20speaking%2C%20it's%20rare%20to%20map%20a%20custom%20domain%20to%20an%20Azure%20Functions%20instance.%20It's%20even%20rarer%20to%20map%20the%20APEX%20domain.%20Therefore%2C%20the%20Azure%20Portal%20doesn't%20support%20this%20feature.%20However%2C%20as%20we%20already%20saw%2C%20we%20can%20use%20either%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpowershell%2Fazure%2Fnew-azureps-module-az%3FWT.mc_id%3Dappsonazure-techcommunity-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20PowerShell%3C%2FA%3E%20or%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2Fwhat-is-azure-cli%3FWT.mc_id%3Dappsonazure-techcommunity-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20CLI%3C%2FA%3E%2C%20or%20ARM%20templates%20to%20add%20the%20root%20domain.%20I%20hope%20this%20post%20helps%20if%20one%20of%20your%20clients'%20requests%20is%20the%20one%20described%20in%20this%20post.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20next%20post%2C%20I'll%20discuss%20how%20to%20bind%20a%20%3CA%20href%3D%22https%3A%2F%2Fletsencrypt.org%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ELet's%20Encrypt%3C%2FA%3E%20generated%20SSL%20certificate%20to%20the%20custom%20APEX%20domain%20on%20Azure%20Function%20app.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3EThis%20article%20was%20originally%20published%20on%20%3CA%20href%3D%22https%3A%2F%2Fdevkimchi.com%2F2020%2F10%2F07%2F3-ways-mapping-apex-domains-to-azure-functions%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDev%20Kimchi%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1646823%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%223-ways-mapping-apex-domains-to-azure-functions-00%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F224761iB69F329CF82F2F92%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%223-ways-mapping-apex-domains-to-azure-functions-00%22%20alt%3D%223-ways-mapping-apex-domains-to-azure-functions-00%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThis%20post%20discusses%20how%20to%20map%20APEX%20domains%20to%20Azure%20Functions%20instance%20in%20three%20different%20ways.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1646823%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Throughout this series, I'm going to show how an Azure Functions instance can map APEX domains, add an SSL certificate and update its public inbound IP address to DNS.

 

 

Let's say there is an Azure Functions instance. One of your customers wants to add a custom domain to the Function app. As long as the custom domain is a sub-domain type like api.contoso.com, it shouldn't be an issue because CNAME mapping is supported out-of-the-box. But what if the customer wants to add an APEX domain?

 

Both APEX domain and root domain point to the same thing like contoso.com.

 

 

Adding the root domain through Azure Portal can't be accomplished with the message above. To add the APEX domain to Azure Functions instance, it requires an A record that needs a public IP address. But Azure Functions instance doesn't support it via the portal.

 

Should we give it up now? Well, not really.

 

 

As always, there's a way to get around. Throughout this post, I'm going to show how to map the APEX domain to an Azure Functions instance in three different ways.

 

Verifying Domain Ownership

 

First of all, you need to verify the domain ownership at the Custom Domains blade of the Function app instance.

 

 

  • Get the Custom Domain Verification ID at the picture above.
  • Add the TXT record, asuid.contoso.com, to your DNS server.
  • Add the A record with the IP address to your DNS server.

 

The verification process can be done via the portal.

 

If you want to run the verification with Azure CLI, please have a look at the link.

 

 

Now, you've verified the domain ownership. But you haven't still yet made the APEX domain mapping.

 

1. Through Azure PowerShell

 

If you can't make it through Azure Portal, Azure PowerShell will be one alternative. Use the Set-AzWebApp cmdlet to map your APEX domain.

 

    $resourceGroupName = "[RESOURCE_GROUP_NAME]"
    $functionAppName = "[FUNCTION_APP_NAME]"
    $domainName = "contoso.com"
    Set-AzWebApp `
        -ResourceGroupName $resourceGroupName `
        -Name $functionAppName `
        -HostNames @( $domainName, "$functionAppName.azurewebsites.net" )

 

When you use Azure PowerShell, you MUST make sure one thing. The -HostNames parameter specified above MUST include the existing domain names (line #7). Otherwise, all existing domains will be removed, and you will get the warning like below:

 

 

If you add all custom domains including the default domain name like *.azurewebsites.net, you will be able to see the screen below:

 

 

2. Through Azure CLI

 

If you prefer to using Azure CLI, use the command, az functionapp config hostname add.

 

    az functionapp config hostname add \
        -g [RESOURCE_GROUP_NAME] \
        -n [FUNCTIONAPP_NAME] \
        --hostname "contoso.com"

 

Unlike Azure PowerShell, you can add one hostname at a time and won't lose the ones already added.

 

3. Through ARM Template

 

You can also use ARM Template instead of command-line commands. Here's the bicep code for it (line #5-8).

 

    resource fncapp 'Microsoft.Web/sites@2020-06-01' = {
        name: functionApp.name
        ...
    }
    
    resource fncappHostname 'Microsoft.Web/sites/hostNameBindings@2020-06-01' = {
        name: '${fncapp.name}/contoso.com'
        location: fncapp.location
    }

 

When the bicep file is compiled to ARM Template, it looks like:

 

    {
      ...
      "resources": [
        ...
        {
          "type": "Microsoft.Web/sites/hostNameBindings",
          "apiVersion": "2020-06-01",
          "name": "[format('{0}/{1}', variables('functionApp').name, 'contoso.com')]",
          "location": "[variables('functionApp').location]",
          "dependsOn": [
            "[resourceId('Microsoft.Web/sites', variables('functionApp').name)]"
          ]
        },
        ...
      ]
      ...
    }

 


 

So far, we've used three different ways to map an APEX domain to Azure Functions instance. Generally speaking, it's rare to map a custom domain to an Azure Functions instance. It's even rarer to map the APEX domain. Therefore, the Azure Portal doesn't support this feature. However, as we already saw, we can use either Azure PowerShell or Azure CLI, or ARM templates to add the root domain. I hope this post helps if one of your clients' requests is the one described in this post.

 

In the next post, I'll discuss how to bind a Let's Encrypt generated SSL certificate to the custom APEX domain on Azure Function app.

 

This article was originally published on Dev Kimchi.