Skip to content

Commit

Permalink
Added app insights and fixed a broken test in support of #466.
Browse files Browse the repository at this point in the history
  • Loading branch information
uncheckederror committed Jul 7, 2024
1 parent 1f4080e commit 2ba9237
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Messaging.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public async Task RegisterAClientAsync()
public async Task GetAllClientsAsync()
{
var _client = await GetHttpClientWithValidBearerTokenAsync();
var response = await _client.GetAsync("/client/all");
var response = await _client.GetAsync("/client/all?page=1");
var clients = await response.Content.ReadFromJsonAsync<ClientRegistration[]>();
Assert.NotNull(clients);
Assert.NotEmpty(clients);
Expand Down
2 changes: 2 additions & 0 deletions Messaging/Messaging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
<UserSecretsId>1828a61a-a56d-4b8c-b4dd-ae4309d19d44</UserSecretsId>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<ApplicationInsightsResourceId>/subscriptions/dd4e7397-befc-4010-84b2-7a6deffd4709/resourceGroups/NumberSearch.Mvc-1/providers/microsoft.insights/components/Messaging</ApplicationInsightsResourceId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.7" />
<PackageReference Include="AWSSDK.S3" Version="3.7.104.25" />
<PackageReference Include="Flurl.Http" Version="4.0.2" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.6" />
Expand Down
3 changes: 3 additions & 0 deletions Messaging/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@
builder.Services.AddDefaultAWSOptions(builder.Configuration.GetAWSOptions());
builder.Services.AddAWSService<IAmazonS3>();

// Add Application Insights
builder.Services.AddApplicationInsightsTelemetry();

//builder.Services.AddHttpLogging(httpLogging =>
// {
// httpLogging.LoggingFields = Microsoft.AspNetCore.HttpLogging.HttpLoggingFields.All;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceGroupName": {
"type": "string",
"defaultValue": "NumberSearch.Mvc-1",
"metadata": {
"_parameterType": "resourceGroup",
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
}
},
"resourceGroupLocation": {
"type": "string",
"defaultValue": "westus2",
"metadata": {
"_parameterType": "location",
"description": "Location of the resource group. Resource groups could have different location than resources."
}
},
"resourceLocation": {
"type": "string",
"defaultValue": "[parameters('resourceGroupLocation')]",
"metadata": {
"_parameterType": "location",
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
}
}
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"name": "[parameters('resourceGroupName')]",
"location": "[parameters('resourceGroupLocation')]",
"apiVersion": "2019-10-01"
},
{
"type": "Microsoft.Resources/deployments",
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat('Messaging', subscription().subscriptionId)))]",
"resourceGroup": "[parameters('resourceGroupName')]",
"apiVersion": "2019-10-01",
"dependsOn": [
"[parameters('resourceGroupName')]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"kind": "web",
"name": "Messaging",
"type": "microsoft.insights/components",
"location": "[parameters('resourceLocation')]",
"properties": {},
"apiVersion": "2015-05-01"
}
]
}
}
}
],
"metadata": {
"_dependencyType": "appInsights.azure"
}
}
8 changes: 8 additions & 0 deletions Messaging/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependencies": {
"appInsights1": {
"type": "appInsights",
"connectionId": "APPLICATIONINSIGHTS_CONNECTION_STRING"
}
}
}
10 changes: 10 additions & 0 deletions Messaging/Properties/serviceDependencies.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dependencies": {
"appInsights1": {
"secretStore": "LocalSecretsFile",
"resourceId": "/subscriptions/[parameters('subscriptionId')]/resourceGroups/[parameters('resourceGroupName')]/providers/microsoft.insights/components/Messaging",
"type": "appInsights.azure",
"connectionId": "APPLICATIONINSIGHTS_CONNECTION_STRING"
}
}
}
7 changes: 5 additions & 2 deletions Messaging/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
"FirstPointOutboundMessageURL": "https://smsapi.1pcom.net/v1/retailsendmessage",
"FirstPointOutboundMMSMessageURL": "https://mmsc01.1pcom.net/MMS_Send"
},
"AllowedHosts": "*"
}
"AllowedHosts": "*",
"ApplicationInsights": {
"ConnectionString": "InstrumentationKey=935b97a7-871d-4595-849d-cf99a5f716ca;IngestionEndpoint=https://westus2-2.in.applicationinsights.azure.com/;LiveEndpoint=https://westus2.livediagnostics.monitor.azure.com/;ApplicationId=2a3a48cf-1332-462b-b6da-ff7bdb3d05f1"
}
}
23 changes: 12 additions & 11 deletions NumberSearch.Ops/NumberSearch.Ops.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
Expand All @@ -8,6 +7,7 @@
<CopyRefAssembliesToPublishDirectory>false</CopyRefAssembliesToPublishDirectory>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
<TieredPGO>true</TieredPGO>
<ApplicationInsightsResourceId>/subscriptions/dd4e7397-befc-4010-84b2-7a6deffd4709/resourceGroups/NumberSearch.Mvc-1/providers/microsoft.insights/components/NumberSearchOps</ApplicationInsightsResourceId>
</PropertyGroup>

<ItemGroup>
Expand All @@ -17,14 +17,15 @@
</PackageReference>
<PackageReference Include="Azure.Storage.Blobs" Version="12.20.0" />
<PackageReference Include="CsvHelper" Version="33.0.1" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.6" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
Expand Down Expand Up @@ -66,25 +67,25 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\images\scaled\billing.webp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\images\scaled\favicon-194x194.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\images\scaled\fusionpbx.webp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\images\scaled\github.webp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\images\scaled\lookup.webp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\images\scaled\teledynamics.webp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\images\scaled\ticketing.webp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\js\site.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceGroupName": {
"type": "string",
"defaultValue": "NumberSearch.Mvc-1",
"metadata": {
"_parameterType": "resourceGroup",
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
}
},
"resourceGroupLocation": {
"type": "string",
"defaultValue": "westus2",
"metadata": {
"_parameterType": "location",
"description": "Location of the resource group. Resource groups could have different location than resources."
}
},
"resourceLocation": {
"type": "string",
"defaultValue": "[parameters('resourceGroupLocation')]",
"metadata": {
"_parameterType": "location",
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
}
}
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"name": "[parameters('resourceGroupName')]",
"location": "[parameters('resourceGroupLocation')]",
"apiVersion": "2019-10-01"
},
{
"type": "Microsoft.Resources/deployments",
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat('NumberSearchOps', subscription().subscriptionId)))]",
"resourceGroup": "[parameters('resourceGroupName')]",
"apiVersion": "2019-10-01",
"dependsOn": [
"[parameters('resourceGroupName')]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"kind": "web",
"name": "NumberSearchOps",
"type": "microsoft.insights/components",
"location": "[parameters('resourceLocation')]",
"properties": {},
"apiVersion": "2015-05-01"
}
]
}
}
}
],
"metadata": {
"_dependencyType": "appInsights.azure"
}
}
5 changes: 5 additions & 0 deletions NumberSearch.Ops/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"mssql1": {
"type": "mssql",
"connectionId": "DefaultConnection"
},
"appInsights1": {
"type": "appInsights",
"connectionId": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"dynamicId": null
}
}
}
7 changes: 7 additions & 0 deletions NumberSearch.Ops/Properties/serviceDependencies.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
"mssql1": {
"type": "mssql.local",
"connectionId": "DefaultConnection"
},
"appInsights1": {
"secretStore": "LocalSecretsFile",
"resourceId": "/subscriptions/[parameters('subscriptionId')]/resourceGroups/[parameters('resourceGroupName')]/providers/microsoft.insights/components/NumberSearchOps",
"type": "appInsights.azure",
"connectionId": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"dynamicId": null
}
}
}
3 changes: 2 additions & 1 deletion NumberSearch.Ops/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
"AllowedHosts": "*",
"ApplicationInsights": {
"InstrumentationKey": "cb42b604-984b-41a3-97a5-444b012c0087"
"InstrumentationKey": "cb42b604-984b-41a3-97a5-444b012c0087",
"ConnectionString": "InstrumentationKey=3df6ba2b-5da0-48c3-8b3d-162fd285f253;IngestionEndpoint=https://westus2-2.in.applicationinsights.azure.com/;LiveEndpoint=https://westus2.livediagnostics.monitor.azure.com/;ApplicationId=7be17be4-5d3d-46f1-bb91-f0b56daef16e"
}
}

0 comments on commit 2ba9237

Please sign in to comment.