diff --git a/Functions/Dockerfile b/Functions/Dockerfile index b36ee4a..044bf83 100644 --- a/Functions/Dockerfile +++ b/Functions/Dockerfile @@ -1,18 +1,37 @@ -FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +#FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +#WORKDIR /app +#EXPOSE 80 +#EXPOSE 443 +# +#FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +#WORKDIR /src +#COPY ["Functions/Functions.csproj", "Functions/"] +#RUN dotnet restore "Functions/Functions.csproj" +#COPY . . +#WORKDIR "/src/Functions" +#RUN dotnet build "Functions.csproj" -c Release -o /app/build +# +#FROM build AS publish +#RUN dotnet publish "Functions.csproj" -c Release -o /app/publish /p:UseAppHost=false +# +#FROM base AS final +#WORKDIR /app +#COPY --from=publish /app/publish . +#ENTRYPOINT ["dotnet", "Functions.dll"] + +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base WORKDIR /app EXPOSE 80 -EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build WORKDIR /src -COPY ["Functions/Functions.csproj", "Functions/"] -RUN dotnet restore "Functions/Functions.csproj" +COPY ["Functions.csproj", "./"] +RUN dotnet restore "./Functions.csproj" COPY . . -WORKDIR "/src/Functions" +WORKDIR "/src/." RUN dotnet build "Functions.csproj" -c Release -o /app/build - FROM build AS publish -RUN dotnet publish "Functions.csproj" -c Release -o /app/publish /p:UseAppHost=false +RUN dotnet publish "Functions.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app diff --git a/TestFunction/Controllers/TestController.cs b/TestFunction/Controllers/TestController.cs new file mode 100644 index 0000000..ed1165e --- /dev/null +++ b/TestFunction/Controllers/TestController.cs @@ -0,0 +1,78 @@ +using Microsoft.AspNetCore.Mvc; + +namespace TestFunction.Controllers; + +[ApiController] +[Route("")] +public class TestController : ControllerBase +{ + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public TestController(ILogger logger) + { + _logger = logger; + } + + [HttpGet] + public IEnumerable 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(); + } + + [HttpPost] + public IEnumerable Post() + { + 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(); + } + + [HttpPatch] + public IEnumerable Patch() + { + 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(); + } + [HttpDelete] + public IEnumerable Delete() + { + 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(); + } + [HttpPut] + public IEnumerable Put() + { + 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(); + } +} \ No newline at end of file diff --git a/TestFunction/Controllers/WeatherForecastController.cs b/TestFunction/Controllers/WeatherForecastController.cs deleted file mode 100644 index 500def6..0000000 --- a/TestFunction/Controllers/WeatherForecastController.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -namespace TestFunction.Controllers; - -[ApiController] -[Route("")] -public class WeatherForecastController : ControllerBase -{ - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - private readonly ILogger _logger; - - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } - - [HttpGet(Name = "GetWeatherForecast")] - public IEnumerable 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(); - } -} \ No newline at end of file diff --git a/TestFunction/Dockerfile b/TestFunction/Dockerfile index 29a8891..660e34d 100644 --- a/TestFunction/Dockerfile +++ b/TestFunction/Dockerfile @@ -1,18 +1,37 @@ -FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +#FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +#WORKDIR /app +#EXPOSE 80 +#EXPOSE 443 +# +#FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +#WORKDIR /src +#COPY ["TestFunction.csproj", "TestFunction/"] +#RUN dotnet restore "TestFunction/TestFunction.csproj" +#COPY . . +#WORKDIR "/src/TestFunction" +#RUN dotnet build "TestFunction.csproj" -c Release -o /app/build +# +#FROM build AS publish +#RUN dotnet publish "TestFunction.csproj" -c Release -o /app/publish /p:UseAppHost=false +# +#FROM base AS final +#WORKDIR /app +#COPY --from=publish /app/publish . +#ENTRYPOINT ["dotnet", "TestFunction.dll"] + +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base WORKDIR /app EXPOSE 80 -EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build WORKDIR /src -COPY ["TestFunction/TestFunction.csproj", "TestFunction/"] -RUN dotnet restore "TestFunction/TestFunction.csproj" +COPY ["TestFunction.csproj", "./"] +RUN dotnet restore "./TestFunction.csproj" COPY . . -WORKDIR "/src/TestFunction" +WORKDIR "/src/." RUN dotnet build "TestFunction.csproj" -c Release -o /app/build - FROM build AS publish -RUN dotnet publish "TestFunction.csproj" -c Release -o /app/publish /p:UseAppHost=false +RUN dotnet publish "TestFunction.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app