@ -0,0 +1,30 @@ | |||||
**/.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 | |||||
!**/.gitignore | |||||
!.git/HEAD | |||||
!.git/config | |||||
!.git/packed-refs | |||||
!.git/refs/heads/** |
@ -0,0 +1,16 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk.Web"> | |||||
<PropertyGroup> | |||||
<TargetFramework>net8.0</TargetFramework> | |||||
<Nullable>enable</Nullable> | |||||
<ImplicitUsings>enable</ImplicitUsings> | |||||
<UserSecretsId>12ea8899-f963-4978-9139-09d18ab72fdc</UserSecretsId> | |||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" /> | |||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" /> | |||||
</ItemGroup> | |||||
</Project> |
@ -0,0 +1,6 @@ | |||||
@AwesomeMicroservices.WebApi_HostAddress = http://localhost:5007 | |||||
GET {{AwesomeMicroservices.WebApi_HostAddress}}/weatherforecast/ | |||||
Accept: application/json | |||||
### |
@ -0,0 +1,33 @@ | |||||
using Microsoft.AspNetCore.Mvc; | |||||
namespace AwesomeMicroservices.WebApi.Controllers | |||||
{ | |||||
[ApiController] | |||||
[Route("[controller]")] | |||||
public class WeatherForecastController : ControllerBase | |||||
{ | |||||
private static readonly string[] Summaries = new[] | |||||
{ | |||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | |||||
}; | |||||
private readonly ILogger<WeatherForecastController> _logger; | |||||
public WeatherForecastController(ILogger<WeatherForecastController> logger) | |||||
{ | |||||
_logger = logger; | |||||
} | |||||
[HttpGet(Name = "GetWeatherForecast")] | |||||
public IEnumerable<WeatherForecast> Get() | |||||
{ | |||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast | |||||
{ | |||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), | |||||
TemperatureC = Random.Shared.Next(-20, 55), | |||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)] | |||||
}) | |||||
.ToArray(); | |||||
} | |||||
} | |||||
} |
@ -0,0 +1,30 @@ | |||||
# 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. | |||||
# This stage is used when running from VS in fast mode (Default for Debug configuration) | |||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base | |||||
USER $APP_UID | |||||
WORKDIR /app | |||||
EXPOSE 8080 | |||||
EXPOSE 8081 | |||||
# This stage is used to build the service project | |||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | |||||
ARG BUILD_CONFIGURATION=Release | |||||
WORKDIR /src | |||||
COPY ["AwesomeMicroservices.WebApi/AwesomeMicroservices.WebApi.csproj", "AwesomeMicroservices.WebApi/"] | |||||
RUN dotnet restore "./AwesomeMicroservices.WebApi/AwesomeMicroservices.WebApi.csproj" | |||||
COPY . . | |||||
WORKDIR "/src/AwesomeMicroservices.WebApi" | |||||
RUN dotnet build "./AwesomeMicroservices.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/build | |||||
# This stage is used to publish the service project to be copied to the final stage | |||||
FROM build AS publish | |||||
ARG BUILD_CONFIGURATION=Release | |||||
RUN dotnet publish "./AwesomeMicroservices.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false | |||||
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration) | |||||
FROM base AS final | |||||
WORKDIR /app | |||||
COPY --from=publish /app/publish . | |||||
ENTRYPOINT ["dotnet", "AwesomeMicroservices.WebApi.dll"] |
@ -0,0 +1,36 @@ | |||||
namespace AwesomeMicroservices.WebApi | |||||
{ | |||||
public class Program | |||||
{ | |||||
public static void Main(string[] args) | |||||
{ | |||||
var builder = WebApplication.CreateBuilder(args); | |||||
// Add services to the container. | |||||
builder.Services.AddControllers(); | |||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle | |||||
builder.Services.AddEndpointsApiExplorer(); | |||||
builder.Services.AddSwaggerGen(); | |||||
var app = builder.Build(); | |||||
// Configure the HTTP request pipeline. | |||||
if (app.Environment.IsDevelopment()) | |||||
{ | |||||
app.UseSwagger(); | |||||
app.UseSwaggerUI(); | |||||
} | |||||
app.UseHttpsRedirection(); | |||||
app.UseAuthorization(); | |||||
app.MapControllers(); | |||||
app.Run(); | |||||
} | |||||
} | |||||
} |
@ -0,0 +1,52 @@ | |||||
{ | |||||
"profiles": { | |||||
"http": { | |||||
"commandName": "Project", | |||||
"launchBrowser": true, | |||||
"launchUrl": "swagger", | |||||
"environmentVariables": { | |||||
"ASPNETCORE_ENVIRONMENT": "Development" | |||||
}, | |||||
"dotnetRunMessages": true, | |||||
"applicationUrl": "http://localhost:5007" | |||||
}, | |||||
"https": { | |||||
"commandName": "Project", | |||||
"launchBrowser": true, | |||||
"launchUrl": "swagger", | |||||
"environmentVariables": { | |||||
"ASPNETCORE_ENVIRONMENT": "Development" | |||||
}, | |||||
"dotnetRunMessages": true, | |||||
"applicationUrl": "https://localhost:7135;http://localhost:5007" | |||||
}, | |||||
"IIS Express": { | |||||
"commandName": "IISExpress", | |||||
"launchBrowser": true, | |||||
"launchUrl": "swagger", | |||||
"environmentVariables": { | |||||
"ASPNETCORE_ENVIRONMENT": "Development" | |||||
} | |||||
}, | |||||
"Container (Dockerfile)": { | |||||
"commandName": "Docker", | |||||
"launchBrowser": true, | |||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", | |||||
"environmentVariables": { | |||||
"ASPNETCORE_HTTPS_PORTS": "8081", | |||||
"ASPNETCORE_HTTP_PORTS": "8080" | |||||
}, | |||||
"publishAllPorts": true, | |||||
"useSSL": true | |||||
} | |||||
}, | |||||
"$schema": "http://json.schemastore.org/launchsettings.json", | |||||
"iisSettings": { | |||||
"windowsAuthentication": false, | |||||
"anonymousAuthentication": true, | |||||
"iisExpress": { | |||||
"applicationUrl": "http://localhost:49517", | |||||
"sslPort": 44336 | |||||
} | |||||
} | |||||
} |
@ -0,0 +1,13 @@ | |||||
namespace AwesomeMicroservices.WebApi | |||||
{ | |||||
public class WeatherForecast | |||||
{ | |||||
public DateOnly Date { get; set; } | |||||
public int TemperatureC { get; set; } | |||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); | |||||
public string? Summary { get; set; } | |||||
} | |||||
} |
@ -0,0 +1,8 @@ | |||||
{ | |||||
"Logging": { | |||||
"LogLevel": { | |||||
"Default": "Information", | |||||
"Microsoft.AspNetCore": "Warning" | |||||
} | |||||
} | |||||
} |
@ -0,0 +1,9 @@ | |||||
{ | |||||
"Logging": { | |||||
"LogLevel": { | |||||
"Default": "Information", | |||||
"Microsoft.AspNetCore": "Warning" | |||||
} | |||||
}, | |||||
"AllowedHosts": "*" | |||||
} |
@ -0,0 +1,22 @@ | |||||
| |||||
Microsoft Visual Studio Solution File, Format Version 12.00 | |||||
# Visual Studio Version 17 | |||||
VisualStudioVersion = 17.12.35527.113 | |||||
MinimumVisualStudioVersion = 10.0.40219.1 | |||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AwesomeMicroservices.WebApi", "AwesomeMicroservices.WebApi\AwesomeMicroservices.WebApi.csproj", "{B0EDD9B6-A3D1-4DCC-B9B3-7000997551BA}" | |||||
EndProject | |||||
Global | |||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||||
Debug|Any CPU = Debug|Any CPU | |||||
Release|Any CPU = Release|Any CPU | |||||
EndGlobalSection | |||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | |||||
{B0EDD9B6-A3D1-4DCC-B9B3-7000997551BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{B0EDD9B6-A3D1-4DCC-B9B3-7000997551BA}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{B0EDD9B6-A3D1-4DCC-B9B3-7000997551BA}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{B0EDD9B6-A3D1-4DCC-B9B3-7000997551BA}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
EndGlobalSection | |||||
GlobalSection(SolutionProperties) = preSolution | |||||
HideSolutionNode = FALSE | |||||
EndGlobalSection | |||||
EndGlobal |