Dela via


Workspace Policy - Get

Hämta principkonfigurationen på API-nivå.

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/policy?api-version=2024-05-01
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/policy?format={format}&api-version=2024-05-01

URI-parametrar

Name I Obligatorisk Typ Description
policyId
path True

PolicyIdName

ID:et för principen.

resourceGroupName
path True

string

minLength: 1
maxLength: 90

Namnet på resursgruppen. Namnet är skiftlägesokänsligt.

serviceName
path True

string

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

Namnet på API Management-tjänsten.

subscriptionId
path True

string (uuid)

ID för målprenumerationen. Värdet måste vara ett UUID.

workspaceId
path True

string

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

Arbetsyteidentifierare. Måste vara unikt i den aktuella API Management-tjänstinstansen.

api-version
query True

string

minLength: 1

DEN API-version som ska användas för den här åtgärden.

format
query

PolicyExportFormat

Format för principexport.

Svar

Name Typ Description
200 OK

PolicyContract

Information om arbetsyteprincip.

Sidhuvuden

ETag: string

Other Status Codes

ErrorResponse

Felsvar som beskriver varför åtgärden misslyckades.

Säkerhet

azure_auth

Azure Active Directory OAuth2-flöde.

Typ: oauth2
Flow: implicit
Auktoriseringswebbadress: https://login.microsoftonline.com/common/oauth2/authorize

Omfattningar

Name Description
user_impersonation personifiera ditt användarkonto

Exempel

ApiManagementGetWorkspacePolicy

Exempelbegäran

GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/policies/policy?api-version=2024-05-01

Exempelsvar

{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/policies/policy",
  "type": "Microsoft.ApiManagement/service/workspaces/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>"
  }
}

Definitioner

Name Description
ErrorAdditionalInfo

Ytterligare information om resurshanteringsfelet.

ErrorDetail

Felinformationen.

ErrorResponse

Felsvar

PolicyContentFormat

Format för policyContent.

PolicyContract

Information om principkontrakt.

PolicyExportFormat

Format för principexport.

PolicyIdName

ID:et för principen.

ErrorAdditionalInfo

Ytterligare information om resurshanteringsfelet.

Name Typ Description
info

object

Ytterligare information.

type

string

Ytterligare informationstyp.

ErrorDetail

Felinformationen.

Name Typ Description
additionalInfo

ErrorAdditionalInfo[]

Ytterligare information om felet.

code

string

Felkoden.

details

ErrorDetail[]

Felinformationen.

message

string

Felmeddelandet.

target

string

Felmålet.

ErrorResponse

Felsvar

Name Typ Description
error

ErrorDetail

Felobjektet.

PolicyContentFormat

Format för policyContent.

Värde Description
xml

Innehållet är infogat och innehållstypen är ett XML-dokument.

xml-link

Princip-XML-dokumentet finns på en HTTP-slutpunkt som är tillgänglig från API Management-tjänsten.

rawxml

Innehållet är infogat och Innehållstyp är ett icke XML-kodat principdokument.

rawxml-link

Principdokumentet är inte XML-kodat och finns på en HTTP-slutpunkt som är tillgänglig från API Management-tjänsten.

PolicyContract

Information om principkontrakt.

Name Typ Standardvärde Description
id

string

Fullständigt kvalificerat resurs-ID för resursen. Ex – /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}

name

string

Namnet på resursen

properties.format

PolicyContentFormat

xml

Format för policyContent.

properties.value

string

Innehållet i principen enligt formatet.

type

string

Resurstypen. Till exempel "Microsoft.Compute/virtualMachines" eller "Microsoft.Storage/storageAccounts"

PolicyExportFormat

Format för principexport.

Värde Description
xml

Innehållet är infogat och innehållstypen är ett XML-dokument.

rawxml

Innehållet är infogat och Innehållstyp är ett icke XML-kodat principdokument.

PolicyIdName

ID:et för principen.

Värde Description
policy