Skip to content

Commit

Permalink
Updating apim policy
Browse files Browse the repository at this point in the history
  • Loading branch information
frasermolyneux committed Nov 7, 2023
1 parent 0b7ba85 commit 4c554da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/abstractions/Models/ApimCustomEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Company.Abstractions.Models
{
public class ApimCustomEvent
{
public string InterfaceId { get; set; }

Check warning on line 10 in src/abstractions/Models/ApimCustomEvent.cs

View workflow job for this annotation

GitHub Actions / func-apps-ci (func-app-pub)

Non-nullable property 'InterfaceId' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 10 in src/abstractions/Models/ApimCustomEvent.cs

View workflow job for this annotation

GitHub Actions / func-apps-ci (func-app-job)

Non-nullable property 'InterfaceId' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string EventName { get; set; }

Check warning on line 11 in src/abstractions/Models/ApimCustomEvent.cs

View workflow job for this annotation

GitHub Actions / func-apps-ci (func-app-pub)

Non-nullable property 'EventName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 11 in src/abstractions/Models/ApimCustomEvent.cs

View workflow job for this annotation

GitHub Actions / func-apps-ci (func-app-job)

Non-nullable property 'EventName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public Dictionary<string, string> AdditionalProperties { get; set; }
}
}
5 changes: 4 additions & 1 deletion src/func-app-sub/AppInsightsCustomEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public async Task RunAppInsightsCustomEventsTrigger([EventHubTrigger("appinsight
continue;
}

TelemetryClient.TrackEvent(messageData.EventName, messageData?.AdditionalProperties);
TelemetryClient.TrackEvent(messageData.EventName, new Dictionary<string, string>()
{
{"InterfaceId", messageData.InterfaceId}
});
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions terraform/api-management-api-func.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,10 @@ resource "azurerm_api_management_api_policy" "funcapp_backend" {
<log-to-eventhub logger-id="${azurerm_api_management_logger.apim_eh_logger[each.value.location].name}">
@{
return new JObject(
new JProperty("InterfaceId", "ID_VehicleTollBooth"),
new JProperty("EventName", context.Operation.Name),
new JProperty("AdditionalProperties", new Dictionary<string, string>(){
{"EventTime", DateTime.UtcNow.ToString()},
{"ServiceName", context.Deployment.ServiceName}
})
new JProperty("EventTime", DateTime.UtcNow.ToString()),
new JProperty("ServiceName", context.Deployment.ServiceName)
).ToString();
}
</log-to-eventhub>
Expand Down

0 comments on commit 4c554da

Please sign in to comment.