在 Azure 中将 API 管理与 Service Fabric 集成Integrate API Management with Service Fabric in Azure

使用 Service Fabric 部署 Azure API 管理是一个高级方案。Deploying Azure API Management with Service Fabric is an advanced scenario. 当需要使用一组丰富的路由规则为后端 Service Fabric 服务发布 API 时,API 管理非常有用。API Management is useful when you need to publish APIs with a rich set of routing rules for your back-end Service Fabric services. 云应用程序通常都需要使用前端网关,为用户、设备或其他应用程序提供同一个入口点。Cloud applications typically need a front-end gateway to provide a single point of ingress for users, devices, or other applications. 在 Service Fabric 中,网关可以是专为流量入口(如 ASP.NET Core 应用程序、事件中心、IoT 中心或 Azure API 管理)设计的任意无状态服务。In Service Fabric, a gateway can be any stateless service designed for traffic ingress such as an ASP.NET Core application, Event Hubs, IoT Hub, or Azure API Management.

本文演示了如何设置 Azure API 管理与 Service Fabric,以在 Service Fabric 中将流量路由至后端服务。This article shows you how to set up Azure API Management with Service Fabric to route traffic to a back-end service in Service Fabric. 完成后,便已将 API 管理部署到 VNET,并已将 API 操作配置为将流量发送到后端无状态服务。When you're finished, you have deployed API Management to a VNET, configured an API operation to send traffic to back-end stateless services. 若要详细了解使用 Service Fabric 的 Azure API 管理方案,请参阅概述一文。To learn more about Azure API Management scenarios with Service Fabric, see the overview article.

备注

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

可用性Availability

重要

由于所需的虚拟网络支持,此功能在 API 管理的高级开发人员层中可用。This feature is available in the Premium and Developer tiers of API Management due to the required virtual network support.

必备条件Prerequisites

开始之前:Before you begin:

网络拓扑Network topology

现在,你在 Azure 上拥有了一个安全的 Windows 群集,可以在子网和专为 API 管理指定的 NSG 中将 API 管理部署到虚拟网络 (VNET)。Now that you have a secure Windows cluster on Azure, deploy API Management to the virtual network (VNET) in the subnet and NSG designated for API Management. 对于本文,API 管理资源管理器模板预配置为使用你在 Windows 群集教程中设置的 VNET、子网和 NSG 的名称。本文将以下拓扑部署到 Azure,其中,API 管理和 Service Fabric 位于同一虚拟网络的子网中:For this article, the API Management Resource Manager template is pre-configured to use the names of the VNET, subnet, and NSG that you set up in the Windows cluster tutorial This article deploys the following topology to Azure in which API Management and Service Fabric are in subnets of the same Virtual Network:

图片标题

登录到 Azure,然后选择订阅Sign in to Azure and select your subscription

执行 Azure 命令之前,登录到你的 Azure 帐户并选择你的订阅。Sign in to your Azure account select your subscription before you execute Azure commands.

Connect-AzAccount -Environment AzureChinaCloud
Get-AzSubscription
Set-AzContext -SubscriptionId <guid>

备注

在 Azure China 中使用 Azure CLI 2.0 之前,请首先运行 az cloud set -n AzureChinaCloud 更改云环境。Before you can use Azure CLI 2.0 in Azure China, please run az cloud set -n AzureChinaCloud first to change the cloud environment. 如果要切换回全局 Azure,请再次运行 az cloud set -n AzureCloudIf you want to switch back to Global Azure, run az cloud set -n AzureCloud again.

az cloud set -n AzureChinaCloud
az login
az account set --subscription <guid>

部署 Service Fabric 后端服务Deploy a Service Fabric back-end service

在配置 API 管理以将流量路由到 Service Fabric 后端服务前,首先需要一个运行的服务来接受请求。Before configuring API Management to route traffic to a Service Fabric back-end service, first you need a running service to accept requests.

使用默认的 Web API 项目模板创建一个基本的无状态 ASP.NET Core 可靠服务。Create a basic stateless ASP.NET Core Reliable Service using the default Web API project template. 这可为服务创建一个 HTTP 终结点,可通过 Azure API 管理公开此终结点。This creates an HTTP endpoint for your service, which you expose through Azure API Management.

以管理员身份启动 Visual Studio 并创建 ASP.NET Core 服务:Start Visual Studio as Administrator and create an ASP.NET Core service:

  1. 在 Visual Studio 中,选择“文件”->“新建项目”。In Visual Studio, select File -> New Project.

  2. 选择“云”下的 Service Fabric 应用程序模板并将其命名为“ApiApplication” 。Select the Service Fabric Application template under Cloud and name it "ApiApplication".

  3. 选择无状态 ASP.NET Core 服务模板并将项目命名为“WebApiService” 。Select the stateless ASP.NET Core service template and name the project "WebApiService".

  4. 选择 Web API ASP.NET Core 2.1 项目模板。Select the Web API ASP.NET Core 2.1 project template.

  5. 创建项目后,打开 PackageRoot\ServiceManifest.xml 并从终结点资源配置中删除 Port 属性:Once the project is created, open PackageRoot\ServiceManifest.xml and remove the Port attribute from the endpoint resource configuration:

    <Resources>
      <Endpoints>
        <Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input" />
      </Endpoints>
    </Resources>
    

    删除端口允许 Service Fabric 从应用程序端口范围动态指定一个端口,可通过群集资源管理器模板中的网络安全组将其打开,从而允许流量从 API 管理流向该端口。Removing the port allows Service Fabric to specify a port dynamically from the application port range, opened through the Network Security Group in the cluster Resource Manager template, allowing traffic to flow to it from API Management.

  6. 可在本地于 Visual Studio 中按下 F5 来验证 Web API。Press F5 in Visual Studio to verify the web API is available locally.

    打开 Service Fabric Explorer 并深入了解 ASP.NET Core 服务的特定实例,以查看服务正在侦听的基址。Open Service Fabric Explorer and drill down to a specific instance of the ASP.NET Core service to see the base address the service is listening on. /api/values 添加到基址,然后在浏览器中打开,这在 Web API 模板的 ValuesController 上调用 Get 方法。Add /api/values to the base address and open it in a browser, which invokes the Get method on the ValuesController in the Web API template. 它会返回模板提供的默认响应,即包含两个字符串的 JSON 数组:It returns the default response that is provided by the template, a JSON array that contains two strings:

    ["value1", "value2"]`
    

    这是你通过 Azure 中的 API 管理公开的终结点。This is the endpoint that you expose through API Management in Azure.

  7. 最后,将应用程序部署到 Azure 中的群集。Finally, deploy the application to your cluster in Azure. 在 Visual Studio 中,右键单击“应用程序”项目,然后选择“发布” 。In Visual Studio, right-click the Application project and select Publish. 提供群集终结点(例如,mycluster.chinaeast.cloudapp.chinacloudapi.cn:19000),将应用程序部署到 Azure 中的 Service Fabric 群集。Provide your cluster endpoint (for example, mycluster.chinaeast.cloudapp.chinacloudapi.cn:19000) to deploy the application to your Service Fabric cluster in Azure.

名为 fabric:/ApiApplication/WebApiService 的 ASP.NET Core 无状态服务现在应在 Azure 的 Service Fabric 群集中运行。An ASP.NET Core stateless service named fabric:/ApiApplication/WebApiService should now be running in your Service Fabric cluster in Azure.

下载资源管理器模板并了解其相关信息Download and understand the Resource Manager templates

下载并保存以下资源管理器模板和参数文件:Download and save the following Resource Manager templates and parameters file:

network-apim.json 模板将新的子网和网络安全组部署在已部署的 Service Fabric 群集所在的虚拟网络中。The network-apim.json template deploys a new subnet and network security group in the virtual network where the Service Fabric cluster is deployed.

以下部分介绍由 apim.json 模板定义的资源 。The following sections describe the resources being defined by the apim.json template. 有关详细信息,请访问每个部分中模板引用文档的链接。For more information, follow the links to the template reference documentation within each section. 文本稍后部分设置了 apim.parameters.json 参数文件中定义的可配置参数 。The configurable parameters defined in the apim.parameters.json parameters file are set later in this article.

Microsoft.ApiManagement/serviceMicrosoft.ApiManagement/service

Microsoft.ApiManagement/service 描述了 API 管理服务实例:名称、SKU 或层级、资源组位置、发布者信息和虚拟网络。Microsoft.ApiManagement/service describes the API Management service instance: name, SKU or tier, resource group location, publisher information, and virtual network.

Microsoft.ApiManagement/service/certificatesMicrosoft.ApiManagement/service/certificates

Microsoft.ApiManagement/service/certificates 用于配置 API 管理安全性。Microsoft.ApiManagement/service/certificates configures API Management security. API 管理必须使用有权访问群集的客户端证书对用于服务发现的 Service Fabric 群集进行身份验证。API Management must authenticate with your Service Fabric cluster for service discovery using a client certificate that has access to your cluster. 本文使用之前在创建 Windows 群集时指定的同一证书,该证书默认可用于访问群集。This article uses the same certificate specified previously when creating the Windows cluster, which by default can be used to access your cluster.

本文对客户端身份验证和群集节点到节点安全性使用相同的证书。This article uses the same certificate for client authentication and cluster node-to-node security. 如果你配置了一个单独的客户端证书,则可以使用它来访问 Service Fabric 群集。You may use a separate client certificate if you have one configured to access your Service Fabric cluster. 提供创建 Service Fabric 群集时指定的群集证书私钥文件 (.pfx) 的“名称”、“密码”和“数据”(base-64 编码字符串) 。Provide the name, password, and data (base-64 encoded string) of the private key file (.pfx) of the cluster certificate that you specified when creating your Service Fabric cluster.

Microsoft.ApiManagement/service/backendsMicrosoft.ApiManagement/service/backends

Microsoft.ApiManagement/service/backends 描述了流量转发到的后端服务。Microsoft.ApiManagement/service/backends describes the backend service that traffic is forwarded to.

对于 Service Fabric 后端,后端是 Service Fabric 群集,而不是特定的 Service Fabric 服务。For Service Fabric backends, the Service Fabric cluster is the backend instead of a specific Service Fabric service. 这允许单个策略路由到群集中的多个服务。This allows a single policy to route to more than one service in the cluster. 如果后端策略中未指定任何服务名称,那么此处的 url 字段是群集中一个服务的完全限定的服务名称,默认情况下所有请求都路由到该服务 。The url field here is a fully qualified service name of a service in your cluster that all requests are routed to by default if no service name is specified in a backend policy. 如果你不打算获取回退服务,可以使用一个假的服务名称,如“fabric:/fake/service”。You may use a fake service name, such as "fabric:/fake/service" if you do not intend to have a fallback service. resourceId 指定群集管理终结点 。resourceId specifies the cluster management endpoint. clientCertificateThumbprint 和 serverCertificateThumbprints 标识用于对群集进行身份验证的证书 。clientCertificateThumbprint and serverCertificateThumbprints identify certificates used to authenticate with the cluster.

Microsoft.ApiManagement/service/productsMicrosoft.ApiManagement/service/products

Microsoft.ApiManagement/service/products 用于创建产品。Microsoft.ApiManagement/service/products creates a product. 在 Azure API 管理中,产品包含一个或多个 API 以及使用配额和使用条款。In Azure API Management, a product contains one or more APIs as well as a usage quota and the terms of use. 一旦产品发布,开发人员可以订阅该产品,并开始使用产品的 API。Once a product is published, developers can subscribe to the product and begin to use the product's APIs.

为产品输入描述性“displayName”和“description” 。Enter a descriptive displayName and description for the product. 对于本文,订阅是必需的,但不需要管理员批准订阅。For this article, a subscription is required but subscription approval by an admin is not. 产品“state”为“已发布”,并对订阅者可见 。This product state is "published" and is visible to subscribers.

Microsoft.ApiManagement/service/apisMicrosoft.ApiManagement/service/apis

Microsoft.ApiManagement/service/apis 用于创建 API。Microsoft.ApiManagement/service/apis creates an API. API 管理中的 API 表示一组可由客户端应用程序调用的操作。An API in API Management represents a set of operations that can be invoked by client applications. 一旦添加操作,该 API 添加到某一产品并可以发布。Once the operations are added, the API is added to a product and can be published. 发布 API 后,它可供开发人员订阅和使用。Once an API is published, it can be subscribed to and used by developers.

  • “displayName”可以是 API 的任意名称 。displayName can be any name for your API. 对于本文,请使用“Service Fabric App”。For this article, use "Service Fabric App".
  • “name”为 API 提供一个唯一且有描述性的名称,例如“service-fabric-app” 。name provides a unique and descriptive name for the API, such as "service-fabric-app". 它显示在开发人员和发布者门户中。It is displayed in the developer and publisher portals.
  • “serviceUrl”引用实现 API 的 HTTP 服务 。serviceUrl references the HTTP service implementing the API. API 管理将请求转发到此地址。API management forwards requests to this address. 对于 Service Fabric 后端,不使用此 URL 值。For Service Fabric backends, this URL value is not used. 你可以在此处设置任何值。You can put any value here. 对于本文,例如“http://servicefabric”。For this article, for example "http://servicefabric".
  • “path”附加到 API 管理服务的基础 URL 。path is appended to the base URL for the API management service. 基础 URL 是常见的由 API 管理服务实例托管的所有 API。The base URL is common for all APIs hosted by an API Management service instance. API 管理通过其后缀区分 API,因此后缀对给定发布者上的每个 API 必须唯一。API Management distinguishes APIs by their suffix and therefore the suffix must be unique for every API for a given publisher.
  • “protocols”确定可用于访问 API 的协议 。protocols determine which protocols can be used to access the API. 对于本文,列出 httphttpsFor this article, list http and https.
  • “path”是 API 的后缀 。path is a suffix for the API. 对于本文,请使用“myapp”。For this article, use "myapp".

Microsoft.ApiManagement/service/apis/operationsMicrosoft.ApiManagement/service/apis/operations

Microsoft.ApiManagement/service/apis/operations 在使用 API 管理中的 API 前,必须向 API 添加操作。Microsoft.ApiManagement/service/apis/operations Before an API in API Management can be used, operations must be added to the API. 外部客户端使用操作与 Service Fabric 群集中运行的 ASP.NET Core 无状态服务进行通信。External clients use an operation to communicate with the ASP.NET Core stateless service running in the Service Fabric cluster.

要添加前端 API 操作,请填写以下值:To add a front-end API operation, fill out the values:

  • “displayName”和“description”描述操作 。displayName and description describe the operation. 对于本文,请使用“Values”。For this article, use "Values".
  • “method”指定 HTTP 谓词 。method specifies the HTTP verb. 对于本文,请指定 GETFor this article, specify GET.
  • “urlTemplate”附加到 API 的基础 URL,并标识单个 HTTP 操作 。urlTemplate is appended to the base URL of the API and identifies a single HTTP operation. 对于本文,如果添加了.NET 后端服务,请使用 /api/values,如果添加了 Java 后端服务,请使用 getMessageFor this article, use /api/values if you added the .NET backend service or getMessage if you added the Java backend service. 默认情况下,在此处指定的 URL 路径是发送到后端 Service Fabric 服务的 URL 路径。By default, the URL path specified here is the URL path sent to the backend Service Fabric service. 如果在此处使用服务所用的相同 URL 路径(例如“/api/values”),则无需进一步修改即可正常执行该操作。If you use the same URL path here that your service uses, such as "/api/values", then the operation works without further modification. 还可以在此处指定一个与后端 Service Fabric 服务使用的 URL 路径不同的 URL 路径,这种情况下,还需要在以后的操作策略中指定路径重写。You may also specify a URL path here that is different from the URL path used by your backend Service Fabric service, in which case you also need to specify a path rewrite in your operation policy later.

Microsoft.ApiManagement/service/apis/policiesMicrosoft.ApiManagement/service/apis/policies

Microsoft.ApiManagement/service/apis/policies 创建将所有内容联系在一起的后端策略。Microsoft.ApiManagement/service/apis/policies creates a backend policy, which ties everything together. 你可以在其中配置将请求路由到的后端 Service Fabric 服务。This is where you configure the backend Service Fabric service to which requests are routed. 可以将此策略应用到任何 API 操作。You can apply this policy to any API operation. 有关详细信息,请参阅策略概述For more information, see Policies overview.

Service Fabric 的后端配置提供以下请求路由控件:The backend configuration for Service Fabric provides the following request routing controls:

  • 服务实例选择,方法是指定硬编码的(例如,"fabric:/myapp/myservice")或从 HTTP 请求中生成的(例如,"fabric:/myapp/users/" + context.Request.MatchedParameters["name"])Service Fabric 服务实例名称。Service instance selection by specifying a Service Fabric service instance name, either hardcoded (for example, "fabric:/myapp/myservice") or generated from the HTTP request (for example, "fabric:/myapp/users/" + context.Request.MatchedParameters["name"]).
  • 分区解析,方法是使用任何 Service Fabric 分区方案生成分区键。Partition resolution by generating a partition key using any Service Fabric partitioning scheme.
  • 用于有状态服务的副本选择。Replica selection for stateful services.
  • 解析重试条件,允许你指定用于重新解析服务位置并重新发送请求的条件。Resolution retry conditions that allow you to specify the conditions for re-resolving a service location and resending a request.

“policyContent”是策略的 JSON 转义 XML 内容 。policyContent is the Json escaped XML contents of the policy. 对于本文,请创建一个将请求直接路由到以前部署的 .NET 或 Java 无状态服务的后端策略。For this article, create a backend policy to route requests directly to the .NET or Java stateless service deployed earlier. 在入站策略下添加 set-backend-service 策略。Add a set-backend-service policy under inbound policies. 如果之前部署了 .NET 后端服务,则将 sf-service-instance-name 值替换为 fabric:/ApiApplication/WebApiService,如果部署了 Java 服务,则替换为 fabric:/EchoServerApplication/EchoServerServiceReplace the sf-service-instance-name value with fabric:/ApiApplication/WebApiService if you previously deployed the .NET backend service, or fabric:/EchoServerApplication/EchoServerService if you deployed the Java service. backend-id 引用一个后端资源,在此示例中为在 apim.json 模板中定义的 Microsoft.ApiManagement/service/backends 资源。backend-id references a backend resource, in this case the Microsoft.ApiManagement/service/backends resource defined in the apim.json template. backend-id 也可引用使用 API 管理 API 创建的另一后端资源。backend-id can also reference another backend resource created using the API Management APIs. 对于本文,请将 backend-id 设置为 service_fabric_backend_name 参数的值。For this article, set backend-id to the value of the service_fabric_backend_name parameter.

<policies>
  <inbound>
    <base/>
    <set-backend-service
        backend-id="servicefabric"
        sf-service-instance-name="service-name"
        sf-resolve-condition="@(context.LastError?.Reason == "BackendConnectionFailure")" />
  </inbound>
  <backend>
    <base/>
  </backend>
  <outbound>
    <base/>
  </outbound>
</policies>

有关完整的 Service Fabric 后端策略属性,请参阅 API 管理后端文档For a full set of Service Fabric back-end policy attributes, refer to the API Management back-end documentation

设置参数和部署 API 管理Set parameters and deploy API Management

在部署的 apim.parameters.json 中填写以下空参数 。Fill in the following empty parameters in the apim.parameters.json for your deployment.

参数Parameter Value
apimInstanceNameapimInstanceName sf-apimsf-apim
apimPublisherEmailapimPublisherEmail myemail@contosos.com
apimSkuapimSku 开发人员Developer
serviceFabricCertificateNameserviceFabricCertificateName sfclustertutorialgroup320171031144217sfclustertutorialgroup320171031144217
certificatePasswordcertificatePassword q6D7nN%6ck@6q6D7nN%6ck@6
serviceFabricCertificateThumbprintserviceFabricCertificateThumbprint C4C1E541AD512B8065280292A8BA6079C3F26F10C4C1E541AD512B8065280292A8BA6079C3F26F10
serviceFabricCertificateserviceFabricCertificate <base-64 编码字符串><base-64 encoded string>
url_pathurl_path /api/values/api/values
clusterHttpManagementEndpointclusterHttpManagementEndpoint https://mysfcluster.chinaeast.cloudapp.chinacloudapi.cn:19080
inbound_policyinbound_policy <XML 字符串><XML string>

“certificatePassword”和“serviceFabricCertificateThumbprint”必须与用于设置群集的群集证书匹配 。certificatePassword and serviceFabricCertificateThumbprint must match the cluster certificate used to set up the cluster.

“serviceFabricCertificate”是 base-64 编码字符串形式的证书,可以使用以下脚本生成 :serviceFabricCertificate is the certificate as a base-64 encoded string, which can be generated using the following script:

$bytes = [System.IO.File]::ReadAllBytes("C:\mycertificates\sfclustertutorialgroup220171109113527.pfx");
$b64 = [System.Convert]::ToBase64String($bytes);
[System.Io.File]::WriteAllText("C:\mycertificates\sfclustertutorialgroup220171109113527.txt", $b64);

inbound_policy 中,如果之前部署了 .NET 后端服务,则将 sf-service-instance-name 值替换为 fabric:/ApiApplication/WebApiService,如果部署了 Java 服务,则替换为 fabric:/EchoServerApplication/EchoServerServiceIn inbound_policy, replace the sf-service-instance-name value with fabric:/ApiApplication/WebApiService if you previously deployed the .NET backend service, or fabric:/EchoServerApplication/EchoServerService if you deployed the Java service. backend-id 引用一个后端资源,在此示例中为在 apim.json 模板中定义的 Microsoft.ApiManagement/service/backends 资源。backend-id references a backend resource, in this case the Microsoft.ApiManagement/service/backends resource defined in the apim.json template. backend-id 也可引用使用 API 管理 API 创建的另一后端资源。backend-id can also reference another backend resource created using the API Management APIs. 对于本文,请将 backend-id 设置为 service_fabric_backend_name 参数的值。For this article, set backend-id to the value of the service_fabric_backend_name parameter.

<policies>
  <inbound>
    <base/>
    <set-backend-service
        backend-id="servicefabric"
        sf-service-instance-name="service-name"
        sf-resolve-condition="@(context.LastError?.Reason == "BackendConnectionFailure")" />
  </inbound>
  <backend>
    <base/>
  </backend>
  <outbound>
    <base/>
  </outbound>
</policies>

使用以下脚本为 API 管理部署资源管理器模板和参数文件:Use the following script to deploy the Resource Manager template and parameter files for API Management:

$groupname = "sfclustertutorialgroup"
$clusterloc="chinaeast"
$templatepath="C:\clustertemplates"

New-AzResourceGroupDeployment -ResourceGroupName $groupname -TemplateFile "$templatepath\network-apim.json" -TemplateParameterFile "$templatepath\network-apim.parameters.json" -Verbose

New-AzResourceGroupDeployment -ResourceGroupName $groupname -TemplateFile "$templatepath\apim.json" -TemplateParameterFile "$templatepath\apim.parameters.json" -Verbose
ResourceGroupName="sfclustertutorialgroup"
az group deployment create --name ApiMgmtNetworkDeployment --resource-group $ResourceGroupName --template-file network-apim.json --parameters @network-apim.parameters.json

az group deployment create --name ApiMgmtDeployment --resource-group $ResourceGroupName --template-file apim.json --parameters @apim.parameters.json

测试Test it

现在可以尝试直接从 Azure 门户通过 API 管理将请求发送到 Service Fabric 中的后端服务。You can now try sending a request to your back-end service in Service Fabric through API Management directly from the Azure portal.

  1. 在 API 管理服务中,选择“API” 。In the API Management service, select API.

  2. 在于之前的步骤中创建的“Service Fabric 应用” API 中,选择“测试” 选项卡,然后选择“值” 操作。In the Service Fabric App API you created in the previous steps, select the Test tab and then the Values operation.

  3. 单击“发送” 按钮,将测试请求发送到后端服务。Click the Send button to send a test request to the backend service. 应该会看到类似于以下内容的 HTTP 响应:You should see an HTTP response similar to:

    HTTP/1.1 200 OK
    
    Transfer-Encoding: chunked
    
    Content-Type: application/json; charset=utf-8
    
    Vary: Origin
    
    Ocp-Apim-Trace-Location: https://apimgmtstodhwklpry2xgkdj.blob.core.chinacloudapi.cn/apiinspectorcontainer/PWSQOq_FCDjGcaI1rdMn8w2-2?sv=2015-07-08&sr=b&sig=MhQhzk%2FEKzE5odlLXRjyVsgzltWGF8OkNzAKaf0B1P0%3D&se=2018-01-28T01%3A04%3A44Z&sp=r&traceId=9f8f1892121e445ea1ae4d2bc8449ce4
    
    Date: Sat, 27 Jan 2018 01:04:44 GMT
    
    ["value1", "value2"]
    

清理资源Clean up resources

群集由群集资源本身以及其他 Azure 资源组成。A cluster is made up of other Azure resources in addition to the cluster resource itself. 若要删除群集及其占用的所有资源,最简单的方式是删除资源组。The simplest way to delete the cluster and all the resources it consumes is to delete the resource group.

登录到 Azure,选择要删除群集的订阅 ID。Sign in to Azure and select the subscription ID with which you want to remove the cluster. 可通过登录到 Azure 门户查找订阅 ID。You can find your subscription ID by logging in to the Azure portal. 使用 Remove-AzResourceGroup cmdlet 删除资源组和所有群集资源。Delete the resource group and all the cluster resources using the Remove-AzResourceGroup cmdlet.

$ResourceGroupName = "sfclustertutorialgroup"
Remove-AzResourceGroup -Name $ResourceGroupName -Force
ResourceGroupName="sfclustertutorialgroup"
az group delete --name $ResourceGroupName

后续步骤Next steps

详细了解如何使用 API 管理Learn more about using API Management.