共用方式為


Api Policy - List By Api

取得 API 層級的原則設定。

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies?api-version=2021-08-01

URI 參數

名稱 位於 必要 類型 Description
apiId
path True

string

minLength: 1
maxLength: 256
pattern: ^[^*#&+:<>?]+$

API 修訂標識碼。 目前 API 管理服務實例中必須是唯一的。 非目前的修訂具有 ;rev=n 作為後綴,其中 n 是修訂編號。

resourceGroupName
path True

string

資源群組的名稱。

serviceName
path True

string

minLength: 1
maxLength: 50
pattern: ^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$

API 管理服務的名稱。

subscriptionId
path True

string

可唯一識別Microsoft Azure 訂用帳戶的訂用帳戶認證。 訂用帳戶標識碼會形成每個服務呼叫 URI 的一部分。

api-version
query True

string

要與用戶端要求搭配使用的 API 版本。

回應

名稱 類型 Description
200 OK

PolicyCollection

Apis 原則集合。

Other Status Codes

ErrorResponse

描述作業失敗原因的錯誤回應。

安全性

azure_auth

Azure Active Directory OAuth2 Flow。

類型: oauth2
Flow: implicit
授權 URL: https://login.microsoftonline.com/common/oauth2/authorize

範圍

名稱 Description
user_impersonation 模擬您的用戶帳戶

範例

ApiManagementListApiPolicies

範例要求

GET https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b59475ff190048040001/policies?api-version=2021-08-01

範例回覆

{
  "value": [
    {
      "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/5600b59475ff190048040001/policies/policy",
      "type": "Microsoft.ApiManagement/service/apis/policies",
      "name": "policy",
      "properties": {
        "value": "<!--\r\n    IMPORTANT:\r\n    - Policy elements can appear only within the <inbound>, <outbound>, <backend> section elements.\r\n    - Only the <forward-request> policy element can appear within the <backend> section element.\r\n    - To apply a policy to the incoming request (before it is forwarded to the backend service), place a corresponding policy element within the <inbound> section element.\r\n    - To apply a policy to the outgoing response (before it is sent back to the caller), place a corresponding policy element within the <outbound> section element.\r\n    - To add a policy position the cursor at the desired insertion point and click on the round button associated with the policy.\r\n    - To remove a policy, delete the corresponding policy statement from the policy document.\r\n    - Position the <base> element within a section element to inherit all policies from the corresponding section element in the enclosing scope.\r\n    - Remove the <base> element to prevent inheriting policies from the corresponding section element in the enclosing scope.\r\n    - Policies are applied in the order of their appearance, from the top down.\r\n-->\r\n<policies>\r\n  <inbound>\r\n    <quota-by-key calls=\"5\" bandwidth=\"2\" renewal-period=\"&#x9;P3Y6M4DT12H30M5S\" counter-key=\"ba\" />\r\n    <base />\r\n  </inbound>\r\n  <backend>\r\n    <base />\r\n  </backend>\r\n  <outbound>\r\n    <log-to-eventhub logger-id=\"apimService1\" partition-key=\"@(context.Subscription.Id)\">\r\n@{\r\n\tRandom Random = new Random();\r\n\t\t\t\tconst string Chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz \";                \r\n                return string.Join(\",\", DateTime.UtcNow, new string(\r\n                    Enumerable.Repeat(Chars, Random.Next(2150400))\r\n                              .Select(s =&gt; s[Random.Next(s.Length)])\r\n                              .ToArray()));\r\n          }                           \r\n                        </log-to-eventhub>\r\n    <base />\r\n  </outbound>\r\n</policies>"
      }
    }
  ],
  "count": 1,
  "nextLink": ""
}

定義

名稱 Description
ErrorFieldContract

錯誤欄位合約。

ErrorResponse

錯誤回應。

PolicyCollection

清單原則作業的回應。

PolicyContentFormat

policyContent 的格式。

PolicyContract

原則合約詳細數據。

ErrorFieldContract

錯誤欄位合約。

名稱 類型 Description
code

string

屬性層級錯誤碼。

message

string

人類可讀取的屬性層級錯誤表示法。

target

string

屬性名稱。

ErrorResponse

錯誤回應。

名稱 類型 Description
error.code

string

服務定義的錯誤碼。 此程式代碼可作為回應中所指定 HTTP 錯誤碼的子狀態。

error.details

ErrorFieldContract[]

要求中傳送無效欄位的清單,以防驗證錯誤。

error.message

string

人類可讀取的錯誤表示法。

PolicyCollection

清單原則作業的回應。

名稱 類型 Description
count

integer (int64)

記錄計數總數。

nextLink

string

如果有的話,下一頁連結。

value

PolicyContract[]

原則合約值。

PolicyContentFormat

policyContent 的格式。

Description
rawxml

內容是內嵌的,內容類型是非 XML 編碼的原則檔。

rawxml-link

原則檔不是 Xml 編碼,而且裝載於可從 API 管理服務存取的 HTTP 端點上。

xml

內容是內嵌的,內容類型是 XML 檔。

xml-link

原則 XML 檔裝載於可從 API 管理服務存取的 HTTP 端點上。

PolicyContract

原則合約詳細數據。

名稱 類型 預設值 Description
id

string

資源的完整資源標識碼。 例如 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}

name

string

資源的名稱

properties.format

PolicyContentFormat

xml

policyContent 的格式。

properties.value

string

原則的內容,如格式所定義。

type

string

資源的型別。 例如“Microsoft.Compute/virtualMachines” 或 “Microsoft.Storage/storageAccounts”