-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a025a61
commit 59827c1
Showing
27 changed files
with
836 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/azds.yaml | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Common | ||
{ | ||
public class WeatherForecast | ||
{ | ||
[JsonIgnore] | ||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] | ||
public int Id { get; set; } | ||
public DateTime Date { get; set; } | ||
|
||
public int TemperatureC { get; set; } | ||
|
||
public string Summary { get; set; } | ||
|
||
public string Location { get; set; } | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
DataPersistor/Controllers/WeatherForecastsPersistorController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.EntityFrameworkCore; | ||
using Common; | ||
using DataPersistor.Data; | ||
|
||
namespace DataPersistor.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
public class WeatherForecastsPersistorController : ControllerBase | ||
{ | ||
private readonly DataPersistorContext _context; | ||
|
||
public WeatherForecastsPersistorController(DataPersistorContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
// GET: api/WeatherForecastsPersistor | ||
[HttpGet] | ||
public async Task<ActionResult<IEnumerable<WeatherForecast>>> GetWeatherForecast() | ||
{ | ||
return await _context.WeatherForecast.ToListAsync(); | ||
} | ||
|
||
// GET: api/WeatherForecastsPersistor/5 | ||
[HttpGet("{id}")] | ||
public async Task<ActionResult<WeatherForecast>> GetWeatherForecast(int id) | ||
{ | ||
var weatherForecast = await _context.WeatherForecast.FindAsync(id); | ||
|
||
if (weatherForecast == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
return weatherForecast; | ||
} | ||
|
||
// PUT: api/WeatherForecastsPersistor/5 | ||
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 | ||
[HttpPut("{id}")] | ||
public async Task<IActionResult> PutWeatherForecast(int id, WeatherForecast weatherForecast) | ||
{ | ||
if (id != weatherForecast.Id) | ||
{ | ||
return BadRequest(); | ||
} | ||
|
||
_context.Entry(weatherForecast).State = EntityState.Modified; | ||
|
||
try | ||
{ | ||
await _context.SaveChangesAsync(); | ||
} | ||
catch (DbUpdateConcurrencyException) | ||
{ | ||
if (!WeatherForecastExists(id)) | ||
{ | ||
return NotFound(); | ||
} | ||
else | ||
{ | ||
throw; | ||
} | ||
} | ||
|
||
return NoContent(); | ||
} | ||
|
||
// POST: api/WeatherForecastsPersistor | ||
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 | ||
[HttpPost] | ||
public async Task<ActionResult<WeatherForecast>> PostWeatherForecast(WeatherForecast weatherForecast) | ||
{ | ||
_context.WeatherForecast.Add(weatherForecast); | ||
await _context.SaveChangesAsync(); | ||
|
||
return CreatedAtAction("GetWeatherForecast", new { id = weatherForecast.Id }, weatherForecast); | ||
} | ||
|
||
// DELETE: api/WeatherForecastsPersistor/5 | ||
[HttpDelete("{id}")] | ||
public async Task<IActionResult> DeleteWeatherForecast(int id) | ||
{ | ||
var weatherForecast = await _context.WeatherForecast.FindAsync(id); | ||
if (weatherForecast == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
_context.WeatherForecast.Remove(weatherForecast); | ||
await _context.SaveChangesAsync(); | ||
|
||
return NoContent(); | ||
} | ||
|
||
private bool WeatherForecastExists(int id) | ||
{ | ||
return _context.WeatherForecast.Any(e => e.Id == id); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using Common; | ||
|
||
namespace DataPersistor.Data | ||
{ | ||
public class DataPersistorContext : DbContext | ||
{ | ||
public DataPersistorContext (DbContextOptions<DataPersistorContext> options) | ||
: base(options) | ||
{ | ||
} | ||
|
||
public DbSet<Common.WeatherForecast> WeatherForecast { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<UserSecretsId>3b3dafd7-1a43-4d83-bc53-1350d82f9fe7</UserSecretsId> | ||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> | ||
<ApplicationInsightsResourceId>/subscriptions/206ee0c3-cbc6-403d-9e80-39628698ac8d/resourceGroups/app-insights/providers/microsoft.insights/components/DataProvider</ApplicationInsightsResourceId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.15.0" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.9"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.11.1" /> | ||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Common\Common.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. | ||
|
||
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base | ||
WORKDIR /app | ||
EXPOSE 80 | ||
EXPOSE 443 | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build | ||
WORKDIR /src | ||
COPY ["DataPersistor/DataPersistor.csproj", "DataPersistor/"] | ||
RUN dotnet restore "DataPersistor/DataPersistor.csproj" | ||
COPY . . | ||
WORKDIR "/src/DataPersistor" | ||
RUN dotnet build "DataPersistor.csproj" -c Release -o /app/build | ||
|
||
FROM build AS publish | ||
RUN dotnet publish "DataPersistor.csproj" -c Release -o /app/publish | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
ENTRYPOINT ["dotnet", "DataPersistor.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace DataPersistor | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
DataPersistor/Properties/ServiceDependencies/local/appInsights1.arm.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "app-insights", | ||
"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": "westeurope", | ||
"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('DataProvider', 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": [ | ||
{ | ||
"name": "DataProvider", | ||
"type": "microsoft.insights/components", | ||
"location": "[parameters('resourceLocation')]", | ||
"kind": "web", | ||
"properties": {}, | ||
"apiVersion": "2015-05-01" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"metadata": { | ||
"_dependencyType": "appInsights.azure" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:45496", | ||
"sslPort": 44368 | ||
} | ||
}, | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"DataPersistor": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"dotnetRunMessages": "true", | ||
"applicationUrl": "https://localhost:5001;http://localhost:5000" | ||
}, | ||
"Docker": { | ||
"commandName": "Docker", | ||
"launchBrowser": true, | ||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", | ||
"publishAllPorts": true, | ||
"useSSL": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"dependencies": { | ||
"mssql1": { | ||
"type": "mssql", | ||
"connectionId": "ConnectionStrings:DataPersistorContext" | ||
}, | ||
"secrets1": { | ||
"type": "secrets" | ||
}, | ||
"appInsights1": { | ||
"type": "appInsights", | ||
"connectionId": "APPINSIGHTS_CONNECTIONSTRING" | ||
} | ||
} | ||
} |
Oops, something went wrong.