weixin_39616348
weixin_39616348
2020-11-21 19:39

[KeyVault] Add logPolicy to KeyVault library pipeline configurations

This change adds logPolicy configuration for all KeyVault data-plane libraries so that requests through the HTTP pipeline will be logged. Here's an example of what the logging looks like when running the helloWorld.ts sample in /keyvault-keys:


λ AZURE_LOG_LEVEL="info" node dist-esm/samples/typescript/helloWorld.js
  azure:core-http:info ServiceClient: using default request policies +0ms
  azure:core-http:info ServiceClient: using default request policies +2ms
  azure:core-http:info ServiceClient: using custom request policies +0ms
  azure:keyvault-keys:info Request: {
  azure:keyvault-keys:info   "streamResponseBody": false,
  azure:keyvault-keys:info   "url": "https://keyvault.vault.azure.net/keys/MyKeyName/create?api-version=7.0",
  azure:keyvault-keys:info   "method": "POST",
  azure:keyvault-keys:info   "headers": {
  azure:keyvault-keys:info     "_headersMap": {
  azure:keyvault-keys:info       "content-type": "REDACTED",
  azure:keyvault-keys:info       "user-agent": "REDACTED",
  azure:keyvault-keys:info       "x-ms-client-request-id": "dd2329d3-50df-455c-b238-4b18223be267"
  azure:keyvault-keys:info     }
  azure:keyvault-keys:info   },
  azure:keyvault-keys:info   "withCredentials": false,
  azure:keyvault-keys:info   "timeout": 0
  azure:keyvault-keys:info } +0ms
  azure:keyvault-keys:info Response status code: 401 +354ms
  azure:keyvault-keys:info Headers: {
  azure:keyvault-keys:info   "_headersMap": {
  azure:keyvault-keys:info     "cache-control": "REDACTED",
  azure:keyvault-keys:info     "connection": "REDACTED",
  azure:keyvault-keys:info     "content-length": "REDACTED",
  azure:keyvault-keys:info     "content-type": "REDACTED",
  azure:keyvault-keys:info     "date": "REDACTED",
  azure:keyvault-keys:info     "expires": "REDACTED",
  azure:keyvault-keys:info     "pragma": "REDACTED",
  azure:keyvault-keys:info     "server": "REDACTED",
  azure:keyvault-keys:info     "strict-transport-security": "REDACTED",
  azure:keyvault-keys:info     "www-authenticate": "REDACTED",
  azure:keyvault-keys:info     "x-aspnet-version": "REDACTED",
  azure:keyvault-keys:info     "x-content-type-options": "REDACTED",
  azure:keyvault-keys:info     "x-ms-keyvault-network-info": "addr=46.244.28.62;act_addr_fam=InterNetwork;",
  azure:keyvault-keys:info     "x-ms-keyvault-region": "centralus",
  azure:keyvault-keys:info     "x-ms-keyvault-service-version": "1.1.0.879",
  azure:keyvault-keys:info     "x-ms-request-id": "e73c7fc3-0a63-467e-8e45-88cdb764298f",
  azure:keyvault-keys:info     "x-powered-by": "REDACTED"
  azure:keyvault-keys:info   }
  azure:keyvault-keys:info } +0ms
  azure:core-http:info Request: {
  azure:core-http:info   "url": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token",
  azure:core-http:info   "method": "POST",
  azure:core-http:info   "headers": {
  azure:core-http:info     "_headersMap": {
  azure:core-http:info       "accept": "REDACTED",
  azure:core-http:info       "content-type": "REDACTED",
  azure:core-http:info       "accept-language": "REDACTED",
  azure:core-http:info       "x-ms-client-request-id": "126e3129-7ba3-4f6a-898d-55967d0cb2d3",
  azure:core-http:info       "user-agent": "REDACTED"
  azure:core-http:info     }
  azure:core-http:info   },
  azure:core-http:info   "withCredentials": false,
  azure:core-http:info   "timeout": 0
  azure:core-http:info } +368ms
  azure:core-http:info Response status code: 200 +395ms
  azure:core-http:info Headers: {
  azure:core-http:info   "_headersMap": {
  azure:core-http:info     "cache-control": "REDACTED",
  azure:core-http:info     "connection": "REDACTED",
  azure:core-http:info     "content-length": "REDACTED",
  azure:core-http:info     "content-type": "REDACTED",
  azure:core-http:info     "date": "REDACTED",
  azure:core-http:info     "expires": "REDACTED",
  azure:core-http:info     "p3p": "REDACTED",
  azure:core-http:info     "pragma": "REDACTED",
  azure:core-http:info     "set-cookie": "REDACTED",
  azure:core-http:info     "strict-transport-security": "REDACTED",
  azure:core-http:info     "x-content-type-options": "REDACTED",
  azure:core-http:info     "x-ms-ests-server": "REDACTED",
  azure:core-http:info     "x-ms-request-id": "3c4f4a5c-4f5a-4bbf-b4c8-16ad75450200"
  azure:core-http:info   }
  azure:core-http:info } +0ms
  azure:keyvault-keys:info Request: {
  azure:keyvault-keys:info   "streamResponseBody": false,
  azure:keyvault-keys:info   "url": "https://keyvault.vault.azure.net/keys/MyKeyName/create?api-version=7.0",
  azure:keyvault-keys:info   "method": "POST",
  azure:keyvault-keys:info   "headers": {
  azure:keyvault-keys:info     "_headersMap": {
  azure:keyvault-keys:info       "content-type": "REDACTED",
  azure:keyvault-keys:info       "user-agent": "REDACTED",
  azure:keyvault-keys:info       "x-ms-client-request-id": "dd2329d3-50df-455c-b238-4b18223be267",
  azure:keyvault-keys:info       "cookie": "REDACTED",
  azure:keyvault-keys:info       "authorization": "REDACTED"
  azure:keyvault-keys:info     }
  azure:keyvault-keys:info   },
  azure:keyvault-keys:info   "withCredentials": false,
  azure:keyvault-keys:info   "timeout": 0
  azure:keyvault-keys:info } +408ms

The core-http section is actually where /identity authenticates with AAD, the logging for that will be more clear when Identity is hooked up to the logger.

该提问来源于开源项目:Azure/azure-sdk-for-js

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

8条回答