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

App Service 網域是直接在 Azure 中管理的自訂網域。App Service domains are custom 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.

必要條件Prerequisites

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

購買 App Service 網域Buy an App Service domain

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

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

  2. 在搜尋列中,搜尋並選取 App Service 網域In the search bar, search for and select App Service Domains.

    入口網站流覽至 Azure App Service 網域

  3. 在 [ App Service 網域 ] 視圖中,按一下 [ 新增]。In the App Service Domains view, click Add.

    按一下 App Service 網域中的 [新增]

  4. 選取 [ 按一下] 以試用 App Service 網域建立體驗的較新版本Select Click to try the newer version of the App Service Domains create experience.

    使用新體驗建立 App Service 網域

[基本] 索引標籤Basics tab

  1. 在 [ 基本 ] 索引標籤中,使用下表設定設定:In the Basics tab, configure the settings using the following table:

    設定Setting 描述Description
    訂用帳戶Subscription 用來購買網域的訂用帳戶。The subscription to use to buy the domain.
    資源群組Resource Group 要放置網域的資源群組。The resource group to put the domain in. 例如,您的應用程式所在的資源群組。For example, the resource group your app is in.
    網域Domain 輸入您想要的網域。Type the domain you want. 例如, contoso.comFor example, contoso.com. 如果您想要的網域無法使用,您可以從可用網域的建議清單中選取,或嘗試不同的網域。If the domain you want is not available, you can select from a list of suggestions of available domains, or try a different domain.

    注意

    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.

  2. 完成時,請按 [下一步:連絡人資訊]When finished, click Next: Contact information.

連絡人資訊索引標籤Contact information tab

  1. >icann 要求提供網域註冊所需的資訊。Supply your information as required by ICANN for the domain registration.

    請務必填寫所有必要欄位,並盡可能正確填寫。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 buy the domain.

  2. 完成時,請按 [下一步: Advanced]When finished, click Next: Advanced.

進階索引標籤Advanced tab

  1. 在 [ Advanced (Advanced )] 索引標籤中,設定選用設定:In the Advanced tab, configure the optional settings:

    設定Setting 描述Description
    自動續約Auto renewal 預設為啟用。Enabled by default. 您 App Service 網域會以一年的增量註冊給您。Your App Service domain is registered to you at one-year increments. 自動更新可確保您的網域註冊不會過期,而且會保留網域的擁有權。Auto renewal makes sure that your domain registration doesn't expire and that you retain ownership of the domain. 續訂時,您的 Azure 訂用帳戶會自動收取年度網域註冊費用。Your Azure subscription is automatically charged the yearly domain registration fee at the time of renewal. 若要退出,請選取 [ 用]。To opt out, select Disable. 如果已停用自動更新,您可以 手動更新If auto-renewal is disabled, you can renew it manually.
    隱私權保護Privacy protection 預設為啟用。Enabled by default. 隱私權保護會從 WHOIS 資料庫中隱藏您的網域註冊連絡人資訊。Privacy protection hides your domain registration contact information from the WHOIS database. 「隱私權保護」已包含在「年度網域註冊」費用中。Privacy protection is already included in the yearly domain registration fee. 若要退出,請選取 [ 用]。To opt out, select Disable.
  2. 完成時,請按 [下一步:標記]When finished, click Next: Tags.

[完成]Finish

  1. 在 [ 標記 ] 索引標籤中,設定您要用於 App Service 網域的標記。In the Tags tab, set the tags you want for your App Service domain. 使用 App Service 網域不需要標記,但這是 Azure 中的一項功能,可協助您管理資源Tagging is not required for using App Service domains, but is a feature in Azure that helps you manage your resources.

  2. [下一步]: [檢查 + 建立]Click Next: Review + create.

  3. 在 [ 審核 + 建立 ] 索引標籤中,檢查您的網域訂單。In the Review + create tab, review your domain order. 完成後,按一下 [建立]。When finished, click Create.

    注意

    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 yearly domain registration fee, usage charges for Azure DNS apply. 如需相關資訊,請參閱 Azure DNS 定價For information, see Azure DNS Pricing.

  4. 網域註冊完成時,您會看到 [ 移至資源 ] 按鈕。When the domain registration is complete, you see a Go to resource button. 選取它以查看其管理頁面。Select it to see it's management page.

    已建立 App Service 網域。

您現在已經準備好將 App Service 應用程式指派給此自訂網域。You're now ready to assign an App Service app to this custom domain.

準備應用程式Prepare the app

若要將自訂 DNS 名稱對應至 Web 應用程式,Web 應用程式的 App Service 方案必須是付費層 (若為 Azure Functions,則為 [共用]、[基本]、[標準]、[進階] 或 [取用])。To map a custom DNS name to a web app, the web app's App Service plan must be a paid tier (Shared, Basic, Standard, Premium, or Consumption for Azure Functions). 在此步驟中,您要確定 App Service 應用程式位於支援的定價層。In this step, you make sure that the App Service app is in the supported pricing tier.

注意

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.

  1. 在頂端搜尋列中,搜尋並選取 [ 應用程式服務]。From the top search bar, search for and select App Services.

    搜尋應用程式服務

  2. 選取應用程式的名稱。Select the name of the app.

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

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

檢查定價層Check the pricing tier

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

    相應增加功能表

  2. 會以藍色框線醒目顯示應用程式目前的層。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 方案) 的 [應用程式] 頁面左側導覽功能表的螢幕擷取畫面。

  3. 如果 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

  1. 選取任何非免費層 (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.

  2. 按一下 [套用]。Click Apply.

    [生產] 類別目錄中自訂網域定價層的螢幕擷取畫面,其中已醒目提示 [執行] 索引標籤、B1 方案和 [套用] 按鈕。

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

    擴充作業確認

將 App Service 網域對應至您的應用程式Map App Service domain to your app

只要在相同的訂用帳戶中,您就可以輕鬆地將 App Service 網域中的主機名稱對應至 App Service 應用程式。It's easy to map a hostname in your App Service domain to an App Service app, as long as it's in the same subscription. 您可以直接在應用程式中對應 App Service 網域或其任何子域,而 Azure 會為您建立必要的 DNS 記錄。You map the App Service domain or any of its subdomain directly in your app, and Azure creates the necessary DNS records for you.

注意

如果網域和應用程式位於不同的訂用帳戶中,您可以將 App Service 網域對應到應用程式,就像 對應外部購買的網域一樣。If the domain and the app are in different subscriptions, you map the App Service domain to the app just like mapping an externally purchased domain. 在此情況下,Azure DNS 是外部網域提供者,而且您需要 手動新增必要的 DNS 記錄In this case, Azure DNS is the external domain provider, and you need to add the required DNS records manually.

對應網域Map the domain

  1. 在應用程式頁面的左側導覽中,移至 [ 設定 ] 區段,然後選取 [ 自訂網域]。In the left navigation of the app page, scroll to the Settings section and select Custom domains.

    顯示 [自訂網域] 功能表的螢幕擷取畫面。

  2. 選取 [新增自訂網域]。Select Add custom domain.

    顯示 [新增主機名稱] 項目的螢幕擷取畫面。

  3. 輸入 App Service 網域 (例如 contoso.com) 或子域 (例如 www.contoso.com) ,然後按一下 [ 驗證]。Type the App Service domain (such as contoso.com) or a subdomain (such as www.contoso.com) and click Validate.

    注意

    如果您在 App Service 功能變數名稱中進行了打字錯誤,頁面底部會出現驗證錯誤,告訴您遺漏某些 DNS 記錄。If you made a typo in the App Service domain name, a verification error appears at the bottom of the page to tell you that you're missing some DNS records. 您不需要針對 App Service 網域手動新增這些記錄。You don't need to add these records manually for an App Service domain. 只要確定您輸入的功能變數名稱正確,再按一下 [ 驗證 ] 即可。Just make sure that you type the domain name correctly and click Validate again.

    顯示驗證錯誤的螢幕擷取畫面。

  4. 接受 [ 主機名稱] 記錄類型 ,然後按一下 [ 新增自訂網域]。Accept the Hostname record type and click Add custom domain.

    顯示 [新增自訂網域] 按鈕的螢幕擷取畫面。

  5. 可能需要一些時間,新的自訂網域才會反映在應用程式的 [自訂網域] 頁面中。It might take some time for the new custom domain to be reflected in the app's Custom Domains page. 重新整理瀏覽器以更新資料。Refresh the browser to update the data.

    顯示新增 CNAME 記錄的螢幕擷取畫面。

    注意

    您自訂網域的 不安全 標籤表示它尚未系結至 TLS/SSL 憑證。A Not Secure label for your custom domain means that it's not yet bound to a TLS/SSL certificate. 任何從瀏覽器到自訂網域的 HTTPS 要求都會收到錯誤或警告 (視瀏覽器而定)。Any HTTPS request from a browser to your custom domain will receive an error or warning, depending on the browser. 若要新增 TLS 繫結,請參閱在 Azure App Service 中使用 TLS/SSL 繫結保護自訂 DNS 名稱To add a TLS binding, see Secure a custom DNS name with a TLS/SSL binding in Azure App Service.

測試自訂網域Test the custom domain

若要測試自訂網域,請在瀏覽器中流覽至該網域。To test the custom domain, navigate to it in the browser.

續訂網域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.

  1. 在搜尋列中,搜尋並選取 App Service 網域In the search bar, search for and select App Service Domains.

    入口網站流覽至 Azure App Service 網域

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

  3. 從網域的左側導覽中,選取 [網域續訂]。From the left navigation of the domain, select Domain renewal. 若要停止自動更新網域,請選取 [ 關閉]。To stop renewing your domain automatically, select Off. 此設定會立即生效。The setting takes effect immediately.

    顯示自動更新網域之選項的螢幕擷取畫面。

    注意

    離開頁面時,請按一下 [確定],以忽略 [將捨棄未儲存的編輯] 錯誤。When navigating away from the page, disregard the "Your unsaved edits will be discarded" error by clicking OK.

若要以手動方式續訂您的網域,請選取 [續訂網域]。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.
  • 在第4天和第12天到期之後,Azure 會傳送額外的通知電子郵件給您。On the 4th and 12th days day after expiration, Azure sends you additional notification emails. 您可以 手動更新 網域。You can manually renew your domain. 在到期後的5天內,已過期網域的 DNS 解析會停止。On the 5th day after expiration, DNS resolution stops for the expired 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. 管理自訂 DNS 記錄:To manage custom DNS records:

  1. 在搜尋列中,搜尋並選取 App Service 網域In the search bar, search for and select App Service Domains.

    入口網站流覽至 Azure App Service 網域

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

  3. 在 [ 總覽 ] 頁面中,選取 [ 管理 DNS 記錄]。From the Overview page, select Manage DNS records.

    顯示何處可以存取 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.

  1. 在搜尋列中,搜尋並選取 App Service 網域In the search bar, search for and select App Service Domains.

    入口網站流覽至 Azure App Service 網域

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

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

    顯示主機名稱系結頁面的螢幕擷取畫面。

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

  5. 在網域的左側導覽中,選取 [總覽]。In the domain's left navigation, select Overview.

  6. 如果已購買網域的取消期間尚未到期,請選取 [取消購買]。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.

    顯示刪除或取消已購買網域之位置的螢幕擷取畫面。

  7. 選取 [ 是] 以確認操作。Confirm the operation by selecting 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 ),請參閱重新 導向至自訂目錄To direct them to a subdirectory, such as public, see Redirect to a custom directory.

下一步Next steps

瞭解如何將自訂的 TLS/SSL 憑證系結至 App Service。Learn how to bind a custom TLS/SSL certificate to App Service.