針對 Azure App Service 購買自訂網域名稱Buy a custom domain name for Azure App Service

App Service 網域是直接在 Azure 中管理的頂層網域。App Service domains are top-level domains that are managed directly in Azure. 它們可以讓 Azure App Service 的自訂網域管理作業變得很簡單。They make it easy to manage custom domains for Azure App Service. 本教學課程會示範如何購買 App Service 網域,並將 DNS 名稱指派給 Azure App Service。This tutorial shows you how to buy an App Service domain and assign DNS names to Azure App Service.

若為 Azure VM 或 Azure 儲存體,請參閱將 App Service 網域指派給 Azure VM 或 Azure 儲存體For Azure VM or Azure Storage, see Assign App Service domain to Azure VM or Azure Storage. 若為雲端服務,請參閱設定 Azure 雲端服務的自訂網域名稱For Cloud Services, see Configuring a custom domain name for an Azure cloud service.


若要完成本教學課程:To complete this tutorial:

準備應用程式Prepare the app


App Service 的免費和共用 (預覽) 主控方案均為基本層,在與其他 App Service 應用程式相同的 Azure 虛擬機器上執行。App Service Free and Shared (preview) hosting plans are base tiers that run on the same Azure virtual machines as other App Service apps. 某些應用程式可能屬於其他客戶。Some apps might belong to other customers. 這些層僅用於開發與測試。These tiers are intended to be used only for development and testing purposes.

若要在 Azure App Service 中使用自訂網域,應用程式的 App Service 方案必須是付費層 (「共用」、「基本」、「標準」或「進階」)。To use custom domains in Azure App Service, your app's App Service plan must be a paid tier (Shared, Basic, Standard, or Premium). 在此步驟中,您要確定應用程式位於支援的定價層。In this step, you make sure that the app is in the supported pricing tier.

登入 AzureSign in to Azure

開啟 Azure 入口網站並使用您的 Azure 帳戶登入。Open the Azure portal and sign in with your Azure account.

從左側功能表,選取 [App Service],然後選取應用程式的名稱。From the left menu, select App Services, and then select the name of the app.

入口網站瀏覽至 Azure 應用程式

您看到 App Service 應用程式的管理分頁。You see the management page of the App Service app.

檢查定價層Check the pricing tier

在應用程式分頁的左側導覽中,捲動到 [設定] 區段,然後選取 [相應增加 (App Service 方案)]。In the left navigation of the app page, scroll to the Settings section and select Scale up (App Service plan).


會以藍色框線醒目顯示應用程式目前的層。The app's current tier is highlighted by a blue border. 請檢查以確定您的應用程式不是位於 F1 層。Check to make sure that the app is not in the F1 tier. F1 層不支援自訂 DNS。Custom DNS is not supported in the F1 tier.


如果 App Service 方案不是位於 F1 層,請關閉 [相應增加] 頁面,然後跳至 [購買網域]If the App Service plan is not in the F1 tier, close the Scale up page and skip to Buy the domain.

相應增加 App Service 方案Scale up the App Service plan

選取任何非免費層 (D1B1B2B3 或「生產」類別中的任何一層)。Select any of the non-free tiers (D1, B1, B2, B3, or any tier in the Production category). 如需其他選項,請按一下 [查看其他選項]。For additional options, click See additional options.

按一下 [套用]Click Apply.


當您看見下列通知時,表示擴充作業已完成。When you see the following notification, the scale operation is complete.


購買網域Buy the domain

定價資訊Pricing Information

如需 Azure App Service 網域的定價資訊, 請流覽App Service 定價頁面, 並向下 App Service 網域。For pricing information on Azure App Service Domains, visit the App Service Pricing page and scroll down to App Service Domain.

登入 AzureSign in to Azure

開啟 Azure 入口網站並使用您的 Azure 帳戶登入。Open the Azure portal and sign in with your Azure account.

啟動購買網域Launch Buy domains

在 [應用程式服務] 索引標籤中,按一下您應用程式的名稱,選取 [設定],然後選取 [自訂網域]In the App Services tab, click the name of your app, select Settings, and then select Custom domains

在 [自訂網域] 頁面中,按一下 [購買網域]。In the Custom domains page, click Buy Domain.


如果您沒看見 [App Service 網域] 區段,則需要移除您 Azure 帳戶的消費限制 (請參閱必要條件)。If you cannot see the App Service Domains section, you need to remove the spending limit on your Azure account (see Prerequisites).

設定網域購買Configure the domain purchase

在 [App Service 網域] 頁面的 [搜尋網域] 方塊中,輸入要購買的網域名稱,然後輸入 EnterIn the App Service Domain page, in the Search for domain box, type the domain name you want to buy and type Enter. 建議的可用網域會顯示在文字方塊下方。The suggested available domains are shown just below the text box. 選取一或多個要購買的網域。Select one or more domains you want to buy.


App Service 網域支援下列頂層網域comnetco.ukorgnlinbizorg.uk,以及 co.inThe following top-level domains are supported by App Service domains: com, net, co.uk, org, nl, in, biz, org.uk, and co.in.

按一下 [連絡人資訊],然後填寫網域的連絡人資訊表單。Click the Contact Information and fill out the domain's contact information form. 完成之後,請按一下 [確定] 以返回 [App Service 網域] 頁面。When finished, click OK to return to the App Service Domain page.

請務必填寫所有必要欄位,並盡可能正確填寫。It is important that you fill out all required fields with as much accuracy as possible. 連絡資訊的資料若不正確,可能會導致無法購買網域。Incorrect data for contact information can result in failure to purchase domains.

接下來,請為網域選取所需選項。Next, select the desired options for your domain. 請參閱下表中的說明:See the following table for explanations:

設定Setting 建議的值Suggested Value 描述Description
隱私權保護Privacy protection 啟用Enable 選擇加入「隱私權保護」,此服務已 免費 包含在購買價格中。Opt in to "Privacy protection", which is included in the purchase price for free. 有些頂層網域受控於不支援隱私權保護的註冊機構,會將之列在 [隱私權保護] 頁面中。Some top-level domains are managed by registrars that do not support privacy protection, and they are listed on the Privacy protection page.
指派預設主機名稱Assign default hostnames www@www and @ 如有需要,請選取所需的主機名稱繫結。Select the desired hostname bindings, if desired. 網域購買作業完成時,即可從選取的主機名稱存取應用程式。When the domain purchase operation is complete, your app can be accessed at the selected hostnames. 如果應用程式受 Azure 流量管理員管理,您就不會看到指派根網域 (@) 的選項,因為流量管理員不支援 A 記錄。If the app is behind Azure Traffic Manager, you don't see the option to assign the root domain (@), because Traffic Manager does not support A records. 您可以在網域購買完成之後變更主機名稱指派。You can make changes to the hostname assignments after the domain purchase completes.

接受條款並購買Accept terms and purchase

按一下 [法律條款] 來檢閱條款與費用,然後按一下 [購買]。Click Legal Terms to review the terms and the charges, then click Buy.


App Service 網域會使用 GoDaddy 進行網域註冊, 並 Azure DNS 來裝載網域。App Service Domains use GoDaddy for domain registration and Azure DNS to host the domains. 除了網域註冊費之外,您也必須支付 Azure DNS 的使用費用。In addition to the domain registration fee, usage charges for Azure DNS apply. 如需相關資訊,請參閱 Azure DNS 定價For information, see Azure DNS Pricing.

回到 [App Service 網域] 頁面,然後按一下 [確定]。Back in the App Service Domain page, click OK. 作業進行中時,您會看到下列通知:While the operation is in progress, you see the following notifications:

測試主機名稱Test the hostnames

如果您已經指派預設主機名稱給應用程式,也會看見針對每個選取主機名稱的成功通知。If you have assigned default hostnames to your app, you also see a success notification for each selected hostname.

您也會在 [自訂網域] 頁面的 [自訂主機名稱] 區段中看到選取的主機名稱。You also see the selected hostnames in the Custom domains page, in the Custom Hostnames section.


您自訂網域的「不安全」標籤表示它尚未系結至 SSL 憑證, 從瀏覽器到您自訂網域的任何 HTTPS 要求都會收到錯誤或警告 (視瀏覽器而定)。A Not Secure label for your custom domain means that it's not yet bound to an SSL certificate, and any HTTPS request from a browser to your custom domain will receive an error or warning, depending on the browser. 若要設定 SSL 系結, 請參閱購買和設定 Azure App Service 的 ssl 憑證To configure SSL binding, see Buy and configure an SSL certificate for Azure App Service.

若要測試主機名稱,請在瀏覽器中瀏覽至列出的主機名稱。To test the hostnames, navigate to the listed hostnames in the browser. 在上述螢幕擷取畫面的範例中, 請嘗試流覽至_kontoso.net_和_www.kontoso.net_。In the example in the preceding screenshot, try navigating to kontoso.net and www.kontoso.net.

將主機名稱指派給應用程式Assign hostnames to app

如果您在購買程式期間選擇不將一或多個預設主機名稱指派給您的應用程式, 或如果您需要指派未列出的主機名稱, 您可以隨時指派主機名稱。If you choose not to assign one or more default hostnames to your app during the purchase process, or if you need to assign a hostname not listed, you can assign a hostname anytime.

您也可以將 App Service 網域中的主機名稱指派給其他任何應用程式。You can also assign hostnames in the App Service Domain to any other app. 其步驟需視 App Service 網域和應用程式是否屬於同一訂用帳戶而定。The steps depend on whether the App Service Domain and the app belong to the same subscription.

  • 不同的訂用帳戶:將來自「App Service 網域」的自訂 DNS 記錄對應至應用程式,就像對應外部購買的網域一樣。Different subscription: Map custom DNS records from the App Service Domain to the app like an externally purchased domain. 如需將自訂 DNS 名稱新增至 App Service 網域的相關資訊,請參閱管理自訂 DNS 記錄For information on adding custom DNS names to an App Service Domain, see Manage custom DNS records. 若要將外部購買的網域對應至應用程式,請參閱將現有的自訂 DNS 名稱對應至 Azure App ServiceTo map an external purchased domain to an app, see Map an existing custom DNS name to Azure App Service.
  • 相同的訂用帳戶:使用下列步驟。Same subscription: Use the following steps.

啟動新增主機名稱Launch add hostname

在 [應用程式服務] 頁面中,選取要指派主機名稱的應用程式名稱,選取 [設定],然後選取 [自訂網域]。In the App Services page, select the name of your app that you want to assign hostnames to, select Settings, and then select Custom domains.

請確定您所購買的網域已列於 [App Service 網域] 區段中,但請不要選取它。Make sure that your purchased domain is listed in the App Service Domains section, but don't select it.


相同訂用帳戶中的所有 App Service 網域,都會顯示在應用程式的 [自訂網域] 頁面中。All App Service Domains in the same subscription are shown in the app's Custom domains page. 如果您的網域已位於應用程式的訂用帳戶中,但您在應用程式的 [自訂網域] 頁面中看不到該網域,請嘗試重新開啟 [自訂網域] 頁面,或是重新整理該網頁。If your domain is in the app's subscription, but you cannot see it in the app's Custom domains page, try reopening the Custom domains page or refresh the webpage. 此外,請透過檢查位於 Azure 入口網站頂端的通知鈴,來取得進度或建立失敗的訊息。Also, check the notification bell at the top of the Azure portal for progress or creation failures.

選取 [新增主機名稱]。Select Add hostname.

設定主機名稱Configure hostname

在 [新增主機名稱] 對話方塊中,輸入 App Service 網域或任何子網域的完整網域名稱。In the Add hostname dialog, type the fully qualified domain name of your App Service Domain or any subdomain. 例如:For example:

  • kontoso.netkontoso.net
  • www.kontoso.netwww.kontoso.net
  • abc.kontoso.netabc.kontoso.net

完成之後,請選取 [驗證]。When finished, select Validate. 系統會自動為您選取主機名稱記錄類型。The hostname record type is automatically selected for you.

選取 [新增主機名稱]。Select Add hostname.

作業完成之後,您會看到成功指派主機名稱的通知。When the operation is complete, you see a success notification for the assigned hostname.

關閉新增主機名稱Close add hostname

在 [新增主機名稱] 頁面中,視需求將其他任何主機名稱指派給您的應用程式。In the Add hostname page, assign any other hostname to your app, as desired. 完成之後,請關閉 [新增主機名稱] 頁面。When finished, close the Add hostname page.

您現在應該會在應用程式的 [自訂網域] 頁面中看到新指派的主機名稱。You should now see the newly assigned hostname(s) in your app's Custom domains page.

測試主機名稱Test the hostnames

請在瀏覽器中瀏覽至列出的主機名稱。Navigate to the listed hostnames in the browser. 在上方螢幕擷取畫面的範例中,嘗試瀏覽至 abc.kontoso.netIn the example in the preceding screenshot, try navigating to abc.kontoso.net.

續訂網域Renew the domain

您購買的 App Service 網域自購買起一年內有效。The App Service domain you bought is valid for one year from the time of purchase. 按照預設,網域會設定為自動續訂下一年度,並使用您的付款方式付費。By default, the domain is configured to renew automatically by charging your payment method for the next year. 您可以手動更新您的功能變數名稱。You can manually renew your domain name.

如果您想要關閉自動續訂,或想要以手動方式續訂網域,請依照下列步驟進行。If you want to turn off automatic renewal, or if you want to manually renew your domain, follow the steps here.

在 [App Service] 索引標籤中,按一下您應用程式的名稱,選取 [設定],然後選取 [自訂網域]。In the App Services tab, click the name of your app, select Settings, and then select Custom domains.

在 [App Service 網域] 區段中,選取您想要設定的網域。In the App Service Domains section, select the domain you want to configure.

從網域的左側導覽中,選取 [網域續訂]。From the left navigation of the domain, select Domain renewal. 若要停止自動續訂您的網域,請選取 [關閉],然後選取 [儲存]。To stop renewing your domain automatically, select Off, and then Save.

若要以手動方式續訂您的網域,請選取 [續訂網域]。To manually renew your domain, select Renew domain. 不過, 在網域到期前90天之前, 此按鈕不是作用中。However, this button is not active until 90 days before the domain's expiration.

如果您的網域更新成功, 您會在24小時內收到電子郵件通知。If your domain renewal is successful, you receive an email notification within 24 hours.

當網域過期時When domain expires

Azure 會處理過期或過期的 App Service 網域, 如下所示:Azure deals with expiring or expired App Service domains as follows:

  • 如果已停用自動更新:在網域到期前90天, 會將更新通知電子郵件傳送給您, 並在入口網站中啟用 [更新網域] 按鈕。If automatic renewal is disabled: 90 days before domain expiration, a renewal notification email is sent to you and the Renew domain button is activated in the portal.
  • 如果已啟用自動更新:在您的網域到期日之後的一天, Azure 會嘗試向您收取功能變數名稱更新的費用。If automatic renewal is enabled: On the day after your domain expiration date, Azure attempts to bill you for the domain name renewal.
  • 如果在自動更新期間發生錯誤 (例如, 您的卡片已過期), 或自動更新已停用, 且您允許網域過期, Azure 會通知您網域到期, 並將您的功能變數名稱提供給您。If an error occurs during automatic renewal (for example, your card on file is expired), or if automatic renewal is disabled and you allow the domain to expire, Azure notifies you of the domain expiration and parks your domain name. 您可以手動更新您的網域。You can manually renew your domain.
  • Azure 會在到期後的第4和第12天, 傳送額外的通知電子郵件給您。On the 4th and 12th days day after expiration, Azure sends you additional notification emails. 您可以手動更新您的網域。You can manually renew your domain.
  • 在到期後的第19天, 您的網域仍會保留, 但會受到兌換費用的限制。On the 19th day after expiration, your domain remains on hold but becomes subject to a redemption fee. 您可以致電客戶支援以更新您的功能變數名稱, 受限於任何適用的更新和兌換費用。You can call customer support to renew your domain name, subject to any applicable renewal and redemption fees.
  • 在到期後的第25天, Azure 會將您的網域放在使用功能變數名稱產業拍賣服務的拍賣上。On the 25th day after expiration, Azure puts your domain up for auction with a domain name industry auction service. 您可以致電客戶支援以更新您的功能變數名稱, 受限於任何適用的更新和兌換費用。You can call customer support to renew your domain name, subject to any applicable renewal and redemption fees.
  • 到期後的30天內, 您就無法再兌換您的網域。On the 30th day after expiration, you're no longer able to redeem your domain.

管理自訂 DNS 記錄Manage custom DNS records

在 Azure 中,App Service 網域的 DNS 記錄是使用 Azure DNS 來管理。In Azure, DNS records for an App Service Domain are managed using Azure DNS. 和針對外部購買的網域一樣,您可以新增、移除及更新 DNS 記錄。You can add, remove, and update DNS records, just like for an externally purchased domain.

開啟 App Service 網域Open App Service Domain

從 Azure 入口網站中的左側功能表,選取 [所有服務] > [App Service 網域]。In the Azure portal, from the left menu, select All services > App Service Domains.

選取要管理的網域。Select the domain to manage.

存取 DNS 區域Access DNS zone

在網域的左側功能表中,選取 [DNS 區域]。In the domain's left menu, select DNS zone.

這個動作會開啟您在 Azure DNS 中之 App Service 網域的 DNS 區域頁面。This action opens the DNS zone page of your App Service Domain in Azure DNS. 如需如何編輯 DNS 記錄的相關資訊,請參閱如何在 Azure 入口網站中管理 DNS 區域For information on how to edit DNS records, see How to manage DNS Zones in the Azure portal.

取消購買 (刪除網域)Cancel purchase (delete domain)

在您購買 App Service 網域之後,可以在五天內取消購買並獲得全額退費。After you purchase the App Service Domain, you have five days to cancel your purchase for a full refund. 您也可以在五天之後刪除 App Service 網域,但無法收到退款。After five days, you can delete the App Service Domain, but cannot receive a refund.

開啟 App Service 網域Open App Service Domain

從 Azure 入口網站中的左側功能表,選取 [所有服務] > [App Service 網域]。In the Azure portal, from the left menu, select All services > App Service Domains.

選取您要取消或刪除的網域。Select the domain to you want to cancel or delete.

刪除主機名稱繫結Delete hostname bindings

在網域的左側功能表中,選取 [主機名稱繫結]。In the domain's left menu, select Hostname bindings. 這裡會列出來自所有 Azure 服務的主機名稱繫結。The hostname bindings from all Azure services are listed here.

您必須先刪除所有主機名稱繫結,才能刪除 App Service 網域。You cannot delete the App Service Domain until all hostname bindings are deleted.

請透過選取 ... > [刪除].來刪除每個主機名稱繫結。Delete each hostname binding by selecting ... > Delete. 刪除所有繫結之後,請選取 [儲存]。After all the bindings are deleted, select Save.

取消或刪除Cancel or delete

在網域的左側功能表中,選取 [概觀]。In the domain's left menu, select Overview.

如果已購買網域的取消期間尚未到期,請選取 [取消購買]。If the cancellation period on the purchased domain has not elapsed, select Cancel purchase. 否則,您會看到 [刪除] 按鈕。Otherwise, you see a Delete button instead. 若要在不退款情況下刪除網域,請選取 [刪除]。To delete the domain without a refund, select Delete.

若要確認作業,請選取 [是]。To confirm the operation, select Yes.

作業完成之後,該網域就會從您的訂用帳戶中釋放,並可再次供任何人購買。After the operation is complete, the domain is released from your subscription and available for anyone to purchase again.

將預設 URL 導向自訂目錄Direct default URL to a custom directory

根據預設,App Service 會將 Web 要求導向應用程式程式碼的根目錄。By default, App Service directs web requests to the root directory of your app code. 若要將這些要求導向子目錄 (例如 public),請參閱將預設 URL 導向自訂目錄To direct them to a subdirectory, such as public, see Direct default URL to a custom directory.