使用 ARM 範本建立您的 Azure 地圖服務 帳戶
您可以使用 Azure Resource Manager (ARM) 範本來建立 Azure 地圖服務 帳戶。 擁有帳戶之後,您可以在網站或行動應用程式中實作 API。
Azure Resource Manager 範本是 JavaScript 物件表示法 (JSON) 檔案,可定義專案的基礎結構和組態。 範本使用宣告式語法。 您不需要撰寫程式設計命令順序來建立部署,即可描述預定的部署。
如果您的環境符合必要條件,而且您很熟悉 ARM 範本,請選取 [部署至 Azure] 按鈕。 範本會在 Azure 入口網站中開啟。
必要條件
若要完成本文:
- 如尚未擁有 Azure 訂用帳戶,請在開始之前先建立免費帳戶。
檢閱範本
本快速入門中使用的範本是來自 Azure 快速入門範本。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "695164742048978243"
}
},
"parameters": {
"accountName": {
"type": "string",
"defaultValue": "[uniqueString(resourceGroup().id)]",
"metadata": {
"description": "The name for your Azure Maps account. This value must be globally unique."
}
},
"location": {
"type": "string",
"allowedValues": [
"westeurope",
"eastus",
"westus2",
"northeurope",
"westcentralus",
"usgovvirginia",
"usgovarizona"
],
"metadata": {
"description": "Specifies the location for all the resources."
}
},
"pricingTier": {
"type": "string",
"defaultValue": "G2",
"allowedValues": [
"G2"
],
"metadata": {
"description": "The pricing tier SKU for the account."
}
},
"kind": {
"type": "string",
"defaultValue": "Gen2",
"allowedValues": [
"Gen2"
],
"metadata": {
"description": "The pricing tier for the account."
}
}
},
"resources": [
{
"type": "Microsoft.Maps/accounts",
"apiVersion": "2023-06-01",
"name": "[parameters('accountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('pricingTier')]"
},
"kind": "[parameters('kind')]"
}
]
}
Azure 地圖服務 帳戶資源定義在此樣本中:
- 微軟。地圖/帳戶:建立 Azure 地圖服務 帳戶。
部署範本
選取以下影像來登入 Azure 並開啟範本。 範本會建立 Azure 地圖服務 帳戶。
選取或輸入下列值。
除非指定,否則請使用預設值來建立您的 Azure 地圖服務 帳戶。
- 訂用帳戶:選取 Azure 訂用帳戶。
- 資源群組:選取 [ 新建],輸入資源群組的唯一名稱,然後選取 [ 確定]。
- 位置:選取位置。
- 帳戶名稱:輸入 Azure 地圖服務 帳戶的名稱,該帳戶必須是全域唯一的。
- 定價層:選取適當的定價層,範本的預設值為 G2。
選取 [檢閱 + 建立]。
在檢閱頁面上確認您的設定,然後選取 [ 建立]。 成功部署之後,您會收到通知:
Azure 入口網站 可用來部署範本。 您也可以使用 Azure PowerShell、Azure CLI 和 REST API。 若要了解其他部署方法,請參閱<部署範本>。
檢閱已部署的資源
您可以使用 Azure 入口網站 來檢查您的 Azure 地圖服務 帳戶並檢視密鑰。 您也可以使用下列 Azure CLI 腳本來列出您的帳戶密鑰。
az maps account keys list --name MyMapsAccount --resource-group MyResourceGroup
清除資源
若不再需要,請刪除資源群組,這也會刪除 Azure 地圖服務 帳戶。 若要使用 Azure CLI 刪除資源群組:
az group delete --name MyResourceGroup
下一步
若要深入瞭解 Azure 地圖服務 和 Azure Resource Manager,請參閱下列文章: