# 连接 Azure 订阅

可以通过连接Azure订阅，在 GitHub 上启用和支付基于使用情况的计费。

可以通过将Azure订阅 ID 连接到 GitHub 上的组织或企业帐户，通过 Azure 支付 GitHub 功能的按流量计费。 请参阅“[Azure订阅付款](/zh/enterprise-server@3.22/billing/concepts/azure-subscriptions)”。

## Prerequisites

* 您必须是要连接到 Azure 的组织或企业帐户 GitHub 的所有者。

* 必须知道 Azure 订阅 ID。 请参阅 Microsoft Docs 中 Azure 门户 [获取订阅和租户 ID](https://learn.microsoft.com/en-us/azure/azure-portal/get-subscription-tenant-id)。

* 必须以能够提供租户范围的管理员同意的用户身份登录Azure，或者安排使用 Microsoft Entra 全局管理员来配置管理员同意工作流。 请参阅“[Azure订阅付款](/zh/enterprise-server@3.22/billing/concepts/azure-subscriptions)”。

## 将Azure订阅连接到组织或企业帐户

1. 访问您的组织或企业。 例如，从[“组织”](https://github.com/settings/organizations?ref_product=github\&ref_type=engagement\&ref_style=text)或[“企业”](https://github.com/settings/enterprises?ref_product=ghec\&ref_type=engagement\&ref_style=text)页面打开GitHub.com。

2. 单击“<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-credit-card" aria-label="credit-card" role="img"><path d="M10.75 9a.75.75 0 0 0 0 1.5h1.5a.75.75 0 0 0 0-1.5h-1.5Z"></path><path d="M0 3.75C0 2.784.784 2 1.75 2h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25ZM14.5 6.5h-13v5.75c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25Zm0-2.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25V5h13Z"></path></svg> Billing & Licensing”，以显示帐户的计费和许可概述\*\*\*\*：
   * 组织帐户：在设置边栏中的“Access”下\*\*\*\*。
   * 企业帐户：以单独的选项卡形式显示在页面顶部\*\*\*\*。

3. 在“Billing & licensing”页的列表中，单击“Payment information”\*\*\*\*。

4. 滚动到页面底部，在“通过 Azure 按使用量计费”右侧，单击 **Add Azure Subscription**。

5. 登录你的 Microsoft 账户。

6. 查看“请求的权限”提示。 如果同意条款，请单击“接受”。

   如果未看到“请求的权限”提示，而是看到指示需要管理员批准的消息，请参阅“[排查 Azure 订阅连接问题](/zh/enterprise-server@3.22/billing/how-tos/troubleshooting/azure-sub-connection)”。

7. 在“选择订阅”下，选择要连接到帐户的 Azure 订阅 ID。

   1. 选择“通过单击‘连接’，代表你确认希望通过所选 Azure 订阅对按流量计费的服务计费”\*\*\*\*。
   2. 单击“连接”。

   要选择 Azure 订阅，必须对订阅拥有所有者权限。 如果默认租户没有正确的权限，则可能需要指定其他租户 ID。 有关详细信息，请参阅 [Azure订阅付款](/zh/enterprise-server@3.22/billing/concepts/azure-subscriptions) 和 Microsoft Docs 中的 [Microsoft 标识平台和 OAuth 2.0 授权代码流](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-authorization-code)。

## 编辑或断开Azure订阅与帐户的连接

如果断开Azure订阅与帐户的连接，则使用情况不能再超过计划中包含的金额。

1. 在“付款信息”页面上要更改的订阅 ID 的右侧。

   * **编辑订阅**：单击<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-pencil" aria-label="Edit Azure Subscription" role="img"><path d="M11.013 1.427a1.75 1.75 0 0 1 2.474 0l1.086 1.086a1.75 1.75 0 0 1 0 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 0 1-.927-.928l.929-3.25c.081-.286.235-.547.445-.758l8.61-8.61Zm.176 4.823L9.75 4.81l-6.286 6.287a.253.253 0 0 0-.064.108l-.558 1.953 1.953-.558a.253.253 0 0 0 .108-.064Zm1.238-3.763a.25.25 0 0 0-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 0 0 0-.354Z"></path></svg>编辑订阅。
   * **删除订阅**单击<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-trash" aria-label="Delete Azure Subscription" role="img"><path d="M11 1.75V3h2.25a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1 0-1.5H5V1.75C5 .784 5.784 0 6.75 0h2.5C10.216 0 11 .784 11 1.75ZM4.496 6.675l.66 6.6a.25.25 0 0 0 .249.225h5.19a.25.25 0 0 0 .249-.225l.66-6.6a.75.75 0 0 1 1.492.149l-.66 6.6A1.748 1.748 0 0 1 10.595 15h-5.19a1.75 1.75 0 0 1-1.741-1.575l-.66-6.6a.75.75 0 1 1 1.492-.15ZM6.5 1.75V3h3V1.75a.25.25 0 0 0-.25-.25h-2.5a.25.25 0 0 0-.25.25Z"></path></svg>删除连接。

## 连接订阅的视频演示

若要连接Azure订阅，需要对 GitHub 和Azure计费门户具有适当的访问权限。 这可能需要在两个不同的人之间进行协调。

若要查看整个过程的演示，请参阅 [通过 Azure 订阅结算 GitHub 消耗](https://www.youtube.com/watch?v=Y-f7JKJ4_8Y) 在 GitHub 的 YouTube 频道。 此视频演示了企业帐户的操作过程。

## 其他阅读材料

* [Azure订阅付款](/zh/enterprise-server@3.22/billing/concepts/azure-subscriptions)
* [Azure订阅参考](/zh/enterprise-server@3.22/billing/reference/azure-subscription)
* [排查 Azure 订阅连接问题](/zh/enterprise-server@3.22/billing/how-tos/troubleshooting/azure-sub-connection)