使用部署按钮从 GitHub 存储库部署模板Use a deployment button to deploy templates from GitHub repository

本文介绍了如何使用“部署到 Azure”按钮从 GitHub 存储库部署模板。This article describes how to use the Deploy to Azure button to deploy templates from a GitHub repository. 可以直接将此按钮添加到你的 GitHub 存储库中的 README.md 文件,也可以将其添加到引用该存储库的网页。You can add the button directly to the README.md file in your GitHub repository or to a web page that references the repository. 此方法仅支持资源组级别的部署。This method only supports resource group level deployment.

使用常用图像Use common image

若要将此按钮添加到网页或存储库,请使用以下图像:To add the button to your web page or repository, use the following image:

<img src="https://aka.ms/deploytoazurebutton"/>

此图像显示为:The image appears as:

“部署到 Azure”按钮

创建用于部署模板的 URLCreate URL for deploying template

若要为模板创建 URL,请从存储库中模板的原始 URL 开始:To create the URL for your template, start with the raw URL to the template in your repo:

https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-storage-account-create/azuredeploy.json

然后,对其进行 URL 编码。Then, URL encode it. 可以使用联机编码器,也可以运行一个命令。You can use an online encoder or run a command. 以下 PowerShell 示例展示了如何对值进行 URL 编码。The following PowerShell example shows how to URL encode a value.

[uri]::EscapeDataString($url)

进行 URL 编码后,示例 URL 具有以下值。The example URL has the following value when URL encoded.

https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F101-storage-account-create%2Fazuredeploy.json

每个链接都以相同的基 URL 开头:Each link starts with the same base URL:

https://portal.azure.cn/#create/Microsoft.Template/uri/

将进行 URL 编码后的模板链接添加到基 URL 的末尾。Add your URL-encoded template link to the end of the base URL.

https://portal.azure.cn/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F101-storage-account-create%2Fazuredeploy.json

你已具有该链接的完整 URL。You have your full URL for the link.

创建“部署到 Azure”按钮Create Deploy to Azure button

最后,将链接和图像放在一起。Finally, put the link and image together.

若要向 GitHub 存储库中的 README.md 文件或者向网页中添加带 Markdown 的按钮,请使用:To add the button with Markdown in the README.md file in your GitHub repository or a web page, use:

[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.cn/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F101-storage-account-create%2Fazuredeploy.json)

对于 HTML,请使用:For HTML, use:

<a href="https://portal.azure.cn/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F101-storage-account-create%2Fazuredeploy.json" target="_blank">
  <img src="https://aka.ms/deploytoazurebutton"/>
</a>

部署模板Deploy the template

若要测试整个解决方案,请选择以下按钮:To test the full solution, select the following button:

“部署到 Azure”Deploy to Azure

门户会显示一个窗格,你可以在其中轻松地提供参数值。The portal displays a pane that allows you to easily provide parameter values. 这些参数预先填充了来自模板的默认值。The parameters are pre-filled with the default values from the template.

使用门户进行部署

后续步骤Next steps