Skip to content

Commit fd5b398

Browse files
committed
Initial Commit
1 parent 644634b commit fd5b398

File tree

83 files changed

+74617
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+74617
-0
lines changed

LoadTestingWebApp/.dockerignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.classpath
2+
**/.dockerignore
3+
**/.env
4+
**/.git
5+
**/.gitignore
6+
**/.project
7+
**/.settings
8+
**/.toolstarget
9+
**/.vs
10+
**/.vscode
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md

LoadTestingWebApp/Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
2+
3+
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
4+
WORKDIR /app
5+
EXPOSE 80
6+
EXPOSE 443
7+
8+
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
9+
WORKDIR /src
10+
COPY ["LoadTestingWebApp.csproj", "."]
11+
RUN dotnet restore "./LoadTestingWebApp.csproj"
12+
COPY . .
13+
WORKDIR "/src/."
14+
RUN dotnet build "LoadTestingWebApp.csproj" -c Release -o /app/build
15+
16+
FROM build AS publish
17+
RUN dotnet publish "LoadTestingWebApp.csproj" -c Release -o /app/publish /p:UseAppHost=false
18+
19+
FROM base AS final
20+
WORKDIR /app
21+
COPY --from=publish /app/publish .
22+
ENTRYPOINT ["dotnet", "LoadTestingWebApp.dll"]
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<UserSecretsId>9b3b608b-f580-40c5-a1da-47885241a5db</UserSecretsId>
8+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
9+
<DockerfileContext>.</DockerfileContext>
10+
<ApplicationInsightsResourceId>/subscriptions/9ee08370-c481-4bd9-9cb3-774d2e306005/resourceGroups/LoadTestingSample/providers/microsoft.insights/components/loadtestinginsights</ApplicationInsightsResourceId>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<Content Remove="C:\Users\david\.nuget\packages\microsoft.azure.cosmos\3.31.2\contentFiles\any\netstandard2.0\ThirdPartyNotice.txt" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
19+
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.31.2" />
20+
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.2" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<Folder Include="Services\" />
25+
</ItemGroup>
26+
27+
</Project>
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.33209.295
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadTestingWebApp", "LoadTestingWebApp.csproj", "{146A299E-5712-41E5-A73A-179F4E47E069}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{146A299E-5712-41E5-A73A-179F4E47E069}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{146A299E-5712-41E5-A73A-179F4E47E069}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{146A299E-5712-41E5-A73A-179F4E47E069}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{146A299E-5712-41E5-A73A-179F4E47E069}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {E8086687-D2A9-4431-BEAE-78E2B5D45088}
24+
EndGlobalSection
25+
EndGlobal

LoadTestingWebApp/Models/Visit.cs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace LoadTestingWebApp.Models;
2+
3+
public record Visit(
4+
string id,
5+
DateTime dateTime
6+
);

LoadTestingWebApp/Pages/Error.cshtml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@page
2+
@model ErrorModel
3+
@{
4+
ViewData["Title"] = "Error";
5+
}
6+
7+
<h1 class="text-danger">Error.</h1>
8+
<h2 class="text-danger">An error occurred while processing your request.</h2>
9+
10+
@if (Model.ShowRequestId)
11+
{
12+
<p>
13+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
14+
</p>
15+
}
16+
17+
<h3>Development Mode</h3>
18+
<p>
19+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
20+
</p>
21+
<p>
22+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
23+
It can result in displaying sensitive information from exceptions to end users.
24+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
25+
and restarting the app.
26+
</p>
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using System.Diagnostics;
4+
5+
namespace LoadTestingWebApp.Pages
6+
{
7+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8+
[IgnoreAntiforgeryToken]
9+
public class ErrorModel : PageModel
10+
{
11+
public string? RequestId { get; set; }
12+
13+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
14+
15+
private readonly ILogger<ErrorModel> _logger;
16+
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
21+
22+
public void OnGet()
23+
{
24+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
25+
}
26+
}
27+
}

LoadTestingWebApp/Pages/Index.cshtml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@page
2+
@model IndexModel
3+
<header class="p-5 mb-5 bg-dark text-white rounded-bottom">
4+
<div class="container-fluid">
5+
<h4 class="display-4 fw-bold">
6+
Azure Load Testing Demo
7+
</h4>
8+
<p class="fs-4">
9+
Your visit have been registered.
10+
</p>
11+
</div>
12+
</header>
13+
<div class="row" data-masonry='{"percentPosition": true }'>
14+
@foreach (LoadTestingWebApp.Models.Visit visit in Model.Visits ?? Enumerable.Empty<LoadTestingWebApp.Models.Visit>())
15+
{
16+
<div class="col-sm-6 col-lg-4 mb-4">
17+
<div class="card">
18+
<h6 class="card-header bg-primary text-white d-flex w-100 justify-content-between">
19+
@visit.dateTime
20+
</h6>
21+
</div>
22+
</div>
23+
}
24+
</div>
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.AspNetCore.Mvc.RazorPages;
2+
using LoadTestingWebApp.Models;
3+
using LoadTestingWebApp.Services;
4+
5+
namespace LoadTestingWebApp.Pages
6+
{
7+
public class IndexModel : PageModel
8+
{
9+
private readonly ILogger<IndexModel> _logger;
10+
11+
private readonly ICosmosService _cosmosService;
12+
13+
public IndexModel(ILogger<IndexModel> logger, ICosmosService cosmosService)
14+
{
15+
_logger = logger;
16+
_cosmosService = cosmosService;
17+
}
18+
19+
public IEnumerable<Visit>? Visits { get; set; }
20+
21+
public async Task OnGetAsync()
22+
{
23+
await _cosmosService.AddVisitAsync(new Visit(id: Guid.NewGuid().ToString(), dateTime: DateTime.Now));
24+
Visits ??= await _cosmosService.RetrieveAllVisitsAsync();
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>@ViewData["Title"] - Load Testing Web App</title>
7+
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
8+
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
9+
<link rel="stylesheet" href="~/LoadTestingWebApp.styles.css" asp-append-version="true" />
10+
</head>
11+
<body>
12+
<header>
13+
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
14+
<div class="container">
15+
<a class="navbar-brand" asp-area="" asp-page="/Index">Load Testing Web App</a>
16+
</div>
17+
</nav>
18+
</header>
19+
<div class="container">
20+
<main role="main" class="pb-3">
21+
@RenderBody()
22+
</main>
23+
</div>
24+
<footer class="border-top footer text-muted">
25+
<div class="container">
26+
&copy; @DateTime.Now.Year - Load Testing Web App
27+
</div>
28+
</footer>
29+
<script src="~/lib/jquery/dist/jquery.min.js"></script>
30+
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
31+
<script src="~/js/site.js" asp-append-version="true"></script>
32+
@await RenderSectionAsync("Scripts", required: false)
33+
</body>
34+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2+
for details on configuring this project to bundle and minify static web assets. */
3+
4+
a.navbar-brand {
5+
white-space: normal;
6+
text-align: center;
7+
word-break: break-all;
8+
}
9+
10+
a {
11+
color: #0077cc;
12+
}
13+
14+
.btn-primary {
15+
color: #fff;
16+
background-color: #1b6ec2;
17+
border-color: #1861ac;
18+
}
19+
20+
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
21+
color: #fff;
22+
background-color: #1b6ec2;
23+
border-color: #1861ac;
24+
}
25+
26+
.border-top {
27+
border-top: 1px solid #e5e5e5;
28+
}
29+
.border-bottom {
30+
border-bottom: 1px solid #e5e5e5;
31+
}
32+
33+
.box-shadow {
34+
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
35+
}
36+
37+
button.accept-policy {
38+
font-size: 1rem;
39+
line-height: inherit;
40+
}
41+
42+
.footer {
43+
position: absolute;
44+
bottom: 0;
45+
width: 100%;
46+
white-space: nowrap;
47+
line-height: 60px;
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
2+
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@using LoadTestingWebApp
2+
@namespace LoadTestingWebApp.Pages
3+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
Layout = "_Layout";
3+
}

LoadTestingWebApp/Program.cs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using LoadTestingWebApp.Services;
2+
3+
var builder = WebApplication.CreateBuilder(args);
4+
5+
// Add services to the container.
6+
builder.Services.AddRazorPages();
7+
builder.Services.AddApplicationInsightsTelemetry();
8+
builder.Services.AddSingleton<ICosmosService, CosmosService>();
9+
10+
var app = builder.Build();
11+
12+
// Configure the HTTP request pipeline.
13+
if (!app.Environment.IsDevelopment())
14+
{
15+
app.UseExceptionHandler("/Error");
16+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
17+
app.UseHsts();
18+
}
19+
20+
app.UseHttpsRedirection();
21+
app.UseStaticFiles();
22+
23+
app.UseRouting();
24+
25+
app.UseAuthorization();
26+
27+
app.MapRazorPages();
28+
29+
app.Run();

0 commit comments

Comments
 (0)