【发布时间】:2019-08-20 09:03:41
【问题描述】:
我正在为我的天蓝色应用程序使用这个 api https://docs.microsoft.com/en-us/rest/api/monitor/activitylogs/list#code-try-0 将数据保存到 Mongodb。 回应是
"value": [
{
"authorization": {
"action": "microsoft.support/supporttickets/write",
"role": "Subscription Admin",
"scope": "/subscriptions/089bd33f-d4ec-47fe-8ba5-0753aa5c5b33/resourceGroups/MSSupportGroup/providers/microsoft.support/supporttickets/115012112305841"
},
"caller": "admin@contoso.com",
"claims": {
"aud": "https://management.core.windows.net/",
"iss": "https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/",
"iat": "1421876371",
"nbf": "1421876371",
"exp": "1421880271",
"ver": "1.0",
"http://schemas.microsoft.com/identity/claims/tenantid": "1e8d8218-c5e7-4578-9acc-9abbd5d23315",
"http://schemas.microsoft.com/claims/authnmethodsreferences": "pwd",
"http://schemas.microsoft.com/identity/claims/objectidentifier": "2468adf0-8211-44e3-95xq-85137af64708",
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn": "admin@contoso.com",
"puid": "20030000801A118C",
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier": "9vckmEGF7zDKk1YzIY8k0t1_EAPaXoeHyPRn6f413zM",
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname": "John",
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname": "Smith",
"name": "John Smith",
"groups": "cacfe77c-e058-4712-83qw-f9b08849fd60,7f71d11d-4c41-4b23-99d2-d32ce7aa621c,31522864-0578-4ea0-9gdc-e66cc564d18c",
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name": "admin@contoso.com",
"appid": "c44b4083-3bq0-49c1-b47d-974e53cbdf3c",
"appidacr": "2",
"http://schemas.microsoft.com/identity/claims/scope": "user_impersonation",
"http://schemas.microsoft.com/claims/authnclassreference": "1"
},
"correlationId": "1e121103-0ba6-4300-ac9d-952bb5d0c80f",
"description": "",
"eventDataId": "44ade6b4-3813-45e6-ae27-7420a95fa2f8",
"eventName": {
"value": "EndRequest",
"localizedValue": "End request"
},
"httpRequest": {
"clientRequestId": "27003b25-91d3-418f-8eb1-29e537dcb249",
"clientIpAddress": "192.168.35.115",
"method": "PUT"
},
"id": "/subscriptions/089bd33f-d4ec-47fe-8ba5-0753aa5c5b33/resourceGroups/MSSupportGroup/providers/microsoft.support/supporttickets/115012112305841/events/44ade6b4-3813-45e6-ae27-7420a95fa2f8/ticks/635574752669792776",
"level": "Informational",
"resourceGroupName": "MSSupportGroup",
"resourceProviderName": {
"value": "microsoft.support",
"localizedValue": "microsoft.support"
},
"operationId": "1e121103-0ba6-4300-ac9d-952bb5d0c80f",
"operationName": {
"value": "microsoft.support/supporttickets/write",
"localizedValue": "microsoft.support/supporttickets/write"
},
"properties": {
"statusCode": "Created"
},
"status": {
"value": "Succeeded",
"localizedValue": "Succeeded"
},
"subStatus": {
"value": "Created",
"localizedValue": "Created (HTTP Status Code: 201)"
},
"eventTimestamp": "2015-01-21T22:14:26.9792776Z",
"submissionTimestamp": "2015-01-21T22:14:39.9936304Z",
"subscriptionId": "089bd33f-d4ec-47fe-8ba5-0753aa5c5b33"
}
],
"nextLink": "https://management.azure.com/########-####-####-####-
############$skiptoken=######"
}
我的课是
public class ActivityLogOB
{
[BsonId]
public ObjectId IDindex { get; set; }
public string id { get; set; }
public SenderAuthorization authorization { get; set; }
public string caller { get; set; }
public LocalizableString category { get; set; }
public Dictionary<string, string> claims { get; set; }
public string correlationId { get; set; }
public string description { get; set; }
public string eventDataId { get; set; }
public LocalizableString eventName { get; set; }
public string eventTimestamp { get; set; }
public HttpRequestInfo httpRequest { get; set; }
public string level { get; set; }
public string operationId { get; set; }
public LocalizableString operationName { get; set; }
public object properties { get; set; }
public string resourceId { get; set; }
public string resourceGroupName { get; set; }
public string subscriptionId { get; set; }
public string subscriptionName { get; set; }
public LocalizableString resourceProviderName { get; set; }
public LocalizableString resourceType { get; set; }
public LocalizableString status { get; set; }
public LocalizableString subStatus { get; set; }
public string submissionTimestamp { get; set; }
public string tenantId { get; set; }
}
尝试隐蔽时出现错误
Dictionary<string, string> claims { get; set; }
此错误:元素“http://schemas.microsoft.com/claims/authnclassreference”无效。 我该如何解决这个问题。
这是我的代码:
public static void ActivityLog_Insert(ActivityLogOB obj, string subscriptionId, string subscriptionName, string time){
var client = new MongoClient(ServerMongodb);
var server = client.GetServer();
var database = server.GetDatabase("ActivityLog");
var collection = database.GetCollection<ActivityLogOB>("ActivityLog " + time);
ActivityLogOB vn = new ActivityLogOB();
vn.authorization = obj.authorization;
vn.caller = obj.caller;
vn.category = obj.category;
vn.claims = obj.claims;
vn.correlationId = obj.correlationId;
vn.description = obj.description;
vn.eventDataId = obj.eventDataId;
vn.eventName = obj.eventName;
vn.eventTimestamp = obj.eventTimestamp;
vn.httpRequest = obj.httpRequest;
vn.id = obj.id;
vn.level = obj.level;
vn.operationId = obj.operationId;
vn.operationName = obj.operationName;
vn.properties = obj.properties;
vn.resourceId = obj.resourceId;
vn.resourceProviderName = obj.resourceProviderName;
vn.resourceType = obj.resourceType;
vn.status = obj.status;
vn.subStatus = obj.subStatus;
vn.submissionTimestamp = obj.submissionTimestamp;
vn.subscriptionId = obj.subscriptionId;
vn.subscriptionName = subscriptionName;
vn.resourceGroupName = obj.resourceGroupName;
vn.tenantId = obj.tenantId;
collection.Insert(vn);
server.Disconnect();
}
【问题讨论】:
标签: c# azure azure-api-management