From 88443117fdd34dc2c167fefa1e80cf2955528299 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 22 Jul 2019 11:33:20 -0700 Subject: [PATCH] Add existingWindowsBackend application to sample apps --- .gitignore | 2 + .../mywebapi-windows/.dockerignore | 20 ++++ .../Controllers/ValuesController.cs | 44 ++++++++ .../mywebapi-windows/Dockerfile | 22 ++++ .../mywebapi-windows/Program.cs | 25 +++++ .../Properties/launchSettings.json | 36 ++++++ .../mywebapi-windows/Startup.cs | 40 +++++++ .../appsettings.Development.json | 10 ++ .../mywebapi-windows/appsettings.json | 15 +++ .../mywebapi-windows/charts/.helmignore | 22 ++++ .../mywebapi-windows/charts/Chart.yaml | 5 + .../charts/templates/NOTES.txt | 21 ++++ .../charts/templates/_helpers.tpl | 32 ++++++ .../charts/templates/deployment.yaml | 57 ++++++++++ .../charts/templates/ingress.yaml | 39 +++++++ .../charts/templates/service.yaml | 19 ++++ .../mywebapi-windows/charts/values.yaml | 49 ++++++++ .../mywebapi-windows/mywebapi.csproj | 18 +++ .../Controllers/HomeController.cs | 51 +++++++++ .../Models/ErrorViewModel.cs | 11 ++ .../webfrontend-linux/Program.cs | 25 +++++ .../Properties/launchSettings.json | 27 +++++ .../webfrontend-linux/Startup.cs | 49 ++++++++ .../webfrontend-linux/Views/Home/About.cshtml | 7 ++ .../Views/Home/Contact.cshtml | 17 +++ .../webfrontend-linux/Views/Home/Index.cshtml | 106 ++++++++++++++++++ .../Views/Shared/Error.cshtml | 22 ++++ .../Views/Shared/_Layout.cshtml | 71 ++++++++++++ .../Shared/_ValidationScriptsPartial.cshtml | 18 +++ .../Views/_ViewImports.cshtml | 3 + .../webfrontend-linux/Views/_ViewStart.cshtml | 3 + .../appsettings.Development.json | 10 ++ .../webfrontend-linux/appsettings.json | 8 ++ .../webfrontend-linux/bundleconfig.json | 24 ++++ .../webfrontend-linux/webfrontend.csproj | 12 ++ .../webfrontend-linux/wwwroot/css/site.css | 35 ++++++ .../wwwroot/css/site.min.css | 1 + .../wwwroot/images/banner1.svg | 1 + .../wwwroot/images/banner2.svg | 1 + .../wwwroot/images/banner3.svg | 1 + .../wwwroot/images/banner4.svg | 1 + .../webfrontend-linux/wwwroot/js/site.js | 1 + .../webfrontend-linux/wwwroot/js/site.min.js | 0 43 files changed, 981 insertions(+) create mode 100644 samples/existingWindowsBackend/mywebapi-windows/.dockerignore create mode 100644 samples/existingWindowsBackend/mywebapi-windows/Controllers/ValuesController.cs create mode 100644 samples/existingWindowsBackend/mywebapi-windows/Dockerfile create mode 100644 samples/existingWindowsBackend/mywebapi-windows/Program.cs create mode 100644 samples/existingWindowsBackend/mywebapi-windows/Properties/launchSettings.json create mode 100644 samples/existingWindowsBackend/mywebapi-windows/Startup.cs create mode 100644 samples/existingWindowsBackend/mywebapi-windows/appsettings.Development.json create mode 100644 samples/existingWindowsBackend/mywebapi-windows/appsettings.json create mode 100644 samples/existingWindowsBackend/mywebapi-windows/charts/.helmignore create mode 100644 samples/existingWindowsBackend/mywebapi-windows/charts/Chart.yaml create mode 100644 samples/existingWindowsBackend/mywebapi-windows/charts/templates/NOTES.txt create mode 100644 samples/existingWindowsBackend/mywebapi-windows/charts/templates/_helpers.tpl create mode 100644 samples/existingWindowsBackend/mywebapi-windows/charts/templates/deployment.yaml create mode 100644 samples/existingWindowsBackend/mywebapi-windows/charts/templates/ingress.yaml create mode 100644 samples/existingWindowsBackend/mywebapi-windows/charts/templates/service.yaml create mode 100644 samples/existingWindowsBackend/mywebapi-windows/charts/values.yaml create mode 100644 samples/existingWindowsBackend/mywebapi-windows/mywebapi.csproj create mode 100644 samples/existingWindowsBackend/webfrontend-linux/Controllers/HomeController.cs create mode 100644 samples/existingWindowsBackend/webfrontend-linux/Models/ErrorViewModel.cs create mode 100644 samples/existingWindowsBackend/webfrontend-linux/Program.cs create mode 100644 samples/existingWindowsBackend/webfrontend-linux/Properties/launchSettings.json create mode 100644 samples/existingWindowsBackend/webfrontend-linux/Startup.cs create mode 100644 samples/existingWindowsBackend/webfrontend-linux/Views/Home/About.cshtml create mode 100644 samples/existingWindowsBackend/webfrontend-linux/Views/Home/Contact.cshtml create mode 100644 samples/existingWindowsBackend/webfrontend-linux/Views/Home/Index.cshtml create mode 100644 samples/existingWindowsBackend/webfrontend-linux/Views/Shared/Error.cshtml create mode 100644 samples/existingWindowsBackend/webfrontend-linux/Views/Shared/_Layout.cshtml create mode 100644 samples/existingWindowsBackend/webfrontend-linux/Views/Shared/_ValidationScriptsPartial.cshtml create mode 100644 samples/existingWindowsBackend/webfrontend-linux/Views/_ViewImports.cshtml create mode 100644 samples/existingWindowsBackend/webfrontend-linux/Views/_ViewStart.cshtml create mode 100644 samples/existingWindowsBackend/webfrontend-linux/appsettings.Development.json create mode 100644 samples/existingWindowsBackend/webfrontend-linux/appsettings.json create mode 100644 samples/existingWindowsBackend/webfrontend-linux/bundleconfig.json create mode 100644 samples/existingWindowsBackend/webfrontend-linux/webfrontend.csproj create mode 100644 samples/existingWindowsBackend/webfrontend-linux/wwwroot/css/site.css create mode 100644 samples/existingWindowsBackend/webfrontend-linux/wwwroot/css/site.min.css create mode 100644 samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner1.svg create mode 100644 samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner2.svg create mode 100644 samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner3.svg create mode 100644 samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner4.svg create mode 100644 samples/existingWindowsBackend/webfrontend-linux/wwwroot/js/site.js create mode 100644 samples/existingWindowsBackend/webfrontend-linux/wwwroot/js/site.min.js diff --git a/.gitignore b/.gitignore index a52a71836..ed43f7906 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ bld/ # Visual Studio 2015 cache/options directory .vs/ +.vscode/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ @@ -71,6 +72,7 @@ artifacts/ *.pidb *.svclog *.scc +*.sln # Chutzpah Test files _Chutzpah* diff --git a/samples/existingWindowsBackend/mywebapi-windows/.dockerignore b/samples/existingWindowsBackend/mywebapi-windows/.dockerignore new file mode 100644 index 000000000..2d15e48e4 --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/.dockerignore @@ -0,0 +1,20 @@ +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.vs +**/.vscode +**/*.*proj.user +**/azds.yaml +**/charts +**/bin +**/obj +**/Dockerfile +**/Dockerfile.develop +**/docker-compose.yml +**/docker-compose.*.yml +**/*.dbmdl +**/*.jfm +**/secrets.dev.yaml +**/values.dev.yaml +**/.toolstarget \ No newline at end of file diff --git a/samples/existingWindowsBackend/mywebapi-windows/Controllers/ValuesController.cs b/samples/existingWindowsBackend/mywebapi-windows/Controllers/ValuesController.cs new file mode 100644 index 000000000..849e2ecab --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/Controllers/ValuesController.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +namespace mywebapi.Controllers +{ + [Route("api/[controller]")] + public class ValuesController : Controller + { + // GET api/values + [HttpGet] + public IEnumerable Get() + { + return new string[] { System.Runtime.InteropServices.RuntimeInformation.OSDescription }; + } + + // GET api/values/5 + [HttpGet("{id}")] + public string Get(int id) + { + return System.Runtime.InteropServices.RuntimeInformation.OSDescription; + } + + // POST api/values + [HttpPost] + public void Post([FromBody]string value) + { + } + + // PUT api/values/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody]string value) + { + } + + // DELETE api/values/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/samples/existingWindowsBackend/mywebapi-windows/Dockerfile b/samples/existingWindowsBackend/mywebapi-windows/Dockerfile new file mode 100644 index 000000000..47b5869a8 --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/Dockerfile @@ -0,0 +1,22 @@ +#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed. +#For more information, please see https://aka.ms/containercompat + +FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-nanoserver-1809 AS base +WORKDIR /app +EXPOSE 80 + +FROM mcr.microsoft.com/dotnet/core/sdk:2.1-nanoserver-1809 AS build +WORKDIR /src +COPY ["mywebapi.csproj", ""] +RUN dotnet restore "mywebapi.csproj" +COPY . . +WORKDIR "/src/" +RUN dotnet build "mywebapi.csproj" -c Release -o /app + +FROM build AS publish +RUN dotnet publish "mywebapi.csproj" -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . +ENTRYPOINT ["dotnet", "mywebapi.dll"] \ No newline at end of file diff --git a/samples/existingWindowsBackend/mywebapi-windows/Program.cs b/samples/existingWindowsBackend/mywebapi-windows/Program.cs new file mode 100644 index 000000000..38b696078 --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/Program.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; + +namespace mywebapi +{ + public class Program + { + public static void Main(string[] args) + { + BuildWebHost(args).Run(); + } + + public static IWebHost BuildWebHost(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup() + .Build(); + } +} diff --git a/samples/existingWindowsBackend/mywebapi-windows/Properties/launchSettings.json b/samples/existingWindowsBackend/mywebapi-windows/Properties/launchSettings.json new file mode 100644 index 000000000..6a289f702 --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/Properties/launchSettings.json @@ -0,0 +1,36 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:62732/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "mywebapi": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:62733/" + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/api/values", + "environmentVariables": {}, + "httpPort": 62733 + } + } +} \ No newline at end of file diff --git a/samples/existingWindowsBackend/mywebapi-windows/Startup.cs b/samples/existingWindowsBackend/mywebapi-windows/Startup.cs new file mode 100644 index 000000000..82bfcde70 --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/Startup.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace mywebapi +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddMvc(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseMvc(); + } + } +} diff --git a/samples/existingWindowsBackend/mywebapi-windows/appsettings.Development.json b/samples/existingWindowsBackend/mywebapi-windows/appsettings.Development.json new file mode 100644 index 000000000..fa8ce71a9 --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/samples/existingWindowsBackend/mywebapi-windows/appsettings.json b/samples/existingWindowsBackend/mywebapi-windows/appsettings.json new file mode 100644 index 000000000..26bb0ac7a --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/appsettings.json @@ -0,0 +1,15 @@ +{ + "Logging": { + "IncludeScopes": false, + "Debug": { + "LogLevel": { + "Default": "Warning" + } + }, + "Console": { + "LogLevel": { + "Default": "Warning" + } + } + } +} diff --git a/samples/existingWindowsBackend/mywebapi-windows/charts/.helmignore b/samples/existingWindowsBackend/mywebapi-windows/charts/.helmignore new file mode 100644 index 000000000..50af03172 --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/charts/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/samples/existingWindowsBackend/mywebapi-windows/charts/Chart.yaml b/samples/existingWindowsBackend/mywebapi-windows/charts/Chart.yaml new file mode 100644 index 000000000..53b69bce0 --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/charts/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for a Windows container backend API +name: mywebapi +version: 0.1.0 diff --git a/samples/existingWindowsBackend/mywebapi-windows/charts/templates/NOTES.txt b/samples/existingWindowsBackend/mywebapi-windows/charts/templates/NOTES.txt new file mode 100644 index 000000000..348a8b63f --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/charts/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mywebapi.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "mywebapi.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mywebapi.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mywebapi.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/samples/existingWindowsBackend/mywebapi-windows/charts/templates/_helpers.tpl b/samples/existingWindowsBackend/mywebapi-windows/charts/templates/_helpers.tpl new file mode 100644 index 000000000..3c8a64516 --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/charts/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "mywebapi.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "mywebapi.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "mywebapi.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/samples/existingWindowsBackend/mywebapi-windows/charts/templates/deployment.yaml b/samples/existingWindowsBackend/mywebapi-windows/charts/templates/deployment.yaml new file mode 100644 index 000000000..20b00b0b7 --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/charts/templates/deployment.yaml @@ -0,0 +1,57 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "mywebapi.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "mywebapi.name" . }} + helm.sh/chart: {{ include "mywebapi.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "mywebapi.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "mywebapi.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + nodeSelector: + "beta.kubernetes.io/os": windows + tolerations: + - key: "sku" + operator: "Equal" + value: "win-node" + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + httpGet: + path: /api/values + port: http + readinessProbe: + httpGet: + path: /api/values + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/samples/existingWindowsBackend/mywebapi-windows/charts/templates/ingress.yaml b/samples/existingWindowsBackend/mywebapi-windows/charts/templates/ingress.yaml new file mode 100644 index 000000000..e72ecc903 --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/charts/templates/ingress.yaml @@ -0,0 +1,39 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "mywebapi.fullname" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app.kubernetes.io/name: {{ include "mywebapi.name" . }} + helm.sh/chart: {{ include "mywebapi.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} + {{- end }} +{{- end }} diff --git a/samples/existingWindowsBackend/mywebapi-windows/charts/templates/service.yaml b/samples/existingWindowsBackend/mywebapi-windows/charts/templates/service.yaml new file mode 100644 index 000000000..99502219c --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/charts/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "mywebapi.fullname" . }} + labels: + app.kubernetes.io/name: {{ template "mywebapi.name" . }} + helm.sh/chart: {{ template "mywebapi.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app.kubernetes.io/name: {{ include "mywebapi.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/samples/existingWindowsBackend/mywebapi-windows/charts/values.yaml b/samples/existingWindowsBackend/mywebapi-windows/charts/values.yaml new file mode 100644 index 000000000..9d2ea527f --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/charts/values.yaml @@ -0,0 +1,49 @@ +# Default values for mywebapi. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: azdspublic/mywebapiwindows + tag: latest + pullPolicy: Always + +nameOverride: "" +fullnameOverride: "myapi" + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/samples/existingWindowsBackend/mywebapi-windows/mywebapi.csproj b/samples/existingWindowsBackend/mywebapi-windows/mywebapi.csproj new file mode 100644 index 000000000..9ac909d67 --- /dev/null +++ b/samples/existingWindowsBackend/mywebapi-windows/mywebapi.csproj @@ -0,0 +1,18 @@ + + + + netcoreapp2.1 + Windows + . + + + + + + + + + + + + diff --git a/samples/existingWindowsBackend/webfrontend-linux/Controllers/HomeController.cs b/samples/existingWindowsBackend/webfrontend-linux/Controllers/HomeController.cs new file mode 100644 index 000000000..6147c4ed4 --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/Controllers/HomeController.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using webfrontend.Models; + +namespace webfrontend.Controllers +{ + public class HomeController : Controller + { + public IActionResult Index() + { + return View(); + } + + public async Task About() +{ + ViewData["Message"] = "Hello from webfrontend."; + + using (var client = new System.Net.Http.HttpClient()) + { + // Call *mywebapi*, and display its response in the page + var request = new System.Net.Http.HttpRequestMessage(); + request.RequestUri = new Uri("http://myapi/api/values/1"); + if (this.Request.Headers.ContainsKey("azds-route-as")) + { + // Propagate the dev space routing header + request.Headers.Add("azds-route-as", this.Request.Headers["azds-route-as"] as IEnumerable); + } + var response = await client.SendAsync(request); + ViewData["Message"] += " Your backend is running on " + await response.Content.ReadAsStringAsync(); + } + + return View(); +} + + public IActionResult Contact() + { + ViewData["Message"] = "Your contact page."; + + return View(); + } + + public IActionResult Error() + { + return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); + } + } +} diff --git a/samples/existingWindowsBackend/webfrontend-linux/Models/ErrorViewModel.cs b/samples/existingWindowsBackend/webfrontend-linux/Models/ErrorViewModel.cs new file mode 100644 index 000000000..a2e0a2b55 --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/Models/ErrorViewModel.cs @@ -0,0 +1,11 @@ +using System; + +namespace webfrontend.Models +{ + public class ErrorViewModel + { + public string RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + } +} \ No newline at end of file diff --git a/samples/existingWindowsBackend/webfrontend-linux/Program.cs b/samples/existingWindowsBackend/webfrontend-linux/Program.cs new file mode 100644 index 000000000..16665345d --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/Program.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; + +namespace webfrontend +{ + public class Program + { + public static void Main(string[] args) + { + BuildWebHost(args).Run(); + } + + public static IWebHost BuildWebHost(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup() + .Build(); + } +} diff --git a/samples/existingWindowsBackend/webfrontend-linux/Properties/launchSettings.json b/samples/existingWindowsBackend/webfrontend-linux/Properties/launchSettings.json new file mode 100644 index 000000000..8ffb2667a --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:55913/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "webfrontend": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:55914/" + } + } +} \ No newline at end of file diff --git a/samples/existingWindowsBackend/webfrontend-linux/Startup.cs b/samples/existingWindowsBackend/webfrontend-linux/Startup.cs new file mode 100644 index 000000000..49bc16b8d --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/Startup.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace webfrontend +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddMvc(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseExceptionHandler("/Home/Error"); + } + + app.UseStaticFiles(); + + app.UseMvc(routes => + { + routes.MapRoute( + name: "default", + template: "{controller=Home}/{action=Index}/{id?}"); + }); + } + } +} diff --git a/samples/existingWindowsBackend/webfrontend-linux/Views/Home/About.cshtml b/samples/existingWindowsBackend/webfrontend-linux/Views/Home/About.cshtml new file mode 100644 index 000000000..3674e37a8 --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/Views/Home/About.cshtml @@ -0,0 +1,7 @@ +@{ + ViewData["Title"] = "About"; +} +

@ViewData["Title"]

+

@ViewData["Message"]

+ +

Use this area to provide additional information.

diff --git a/samples/existingWindowsBackend/webfrontend-linux/Views/Home/Contact.cshtml b/samples/existingWindowsBackend/webfrontend-linux/Views/Home/Contact.cshtml new file mode 100644 index 000000000..a11a1867c --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/Views/Home/Contact.cshtml @@ -0,0 +1,17 @@ +@{ + ViewData["Title"] = "Contact"; +} +

@ViewData["Title"]

+

@ViewData["Message"]

+ +
+ One Microsoft Way
+ Redmond, WA 98052-6399
+ P: + 425.555.0100 +
+ +
+ Support: Support@example.com
+ Marketing: Marketing@example.com +
diff --git a/samples/existingWindowsBackend/webfrontend-linux/Views/Home/Index.cshtml b/samples/existingWindowsBackend/webfrontend-linux/Views/Home/Index.cshtml new file mode 100644 index 000000000..f804781a3 --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/Views/Home/Index.cshtml @@ -0,0 +1,106 @@ +@{ + ViewData["Title"] = "Home Page"; +} + + + + diff --git a/samples/existingWindowsBackend/webfrontend-linux/Views/Shared/Error.cshtml b/samples/existingWindowsBackend/webfrontend-linux/Views/Shared/Error.cshtml new file mode 100644 index 000000000..ec2ea6bd0 --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/Views/Shared/Error.cshtml @@ -0,0 +1,22 @@ +@model ErrorViewModel +@{ + ViewData["Title"] = "Error"; +} + +

Error.

+

An error occurred while processing your request.

+ +@if (Model.ShowRequestId) +{ +

+ Request ID: @Model.RequestId +

+} + +

Development Mode

+

+ Swapping to Development environment will display more detailed information about the error that occurred. +

+

+ Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. +

diff --git a/samples/existingWindowsBackend/webfrontend-linux/Views/Shared/_Layout.cshtml b/samples/existingWindowsBackend/webfrontend-linux/Views/Shared/_Layout.cshtml new file mode 100644 index 000000000..4d7eab6cd --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/Views/Shared/_Layout.cshtml @@ -0,0 +1,71 @@ + + + + + + @ViewData["Title"] - webfrontend + + + + + + + + + + + + +
+ @RenderBody() +
+
+

© 2018 - webfrontend

+
+
+ + + + + + + + + + + + + @RenderSection("Scripts", required: false) + + diff --git a/samples/existingWindowsBackend/webfrontend-linux/Views/Shared/_ValidationScriptsPartial.cshtml b/samples/existingWindowsBackend/webfrontend-linux/Views/Shared/_ValidationScriptsPartial.cshtml new file mode 100644 index 000000000..a699aafa9 --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/Views/Shared/_ValidationScriptsPartial.cshtml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/samples/existingWindowsBackend/webfrontend-linux/Views/_ViewImports.cshtml b/samples/existingWindowsBackend/webfrontend-linux/Views/_ViewImports.cshtml new file mode 100644 index 000000000..cf6f517b0 --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/Views/_ViewImports.cshtml @@ -0,0 +1,3 @@ +@using webfrontend +@using webfrontend.Models +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/samples/existingWindowsBackend/webfrontend-linux/Views/_ViewStart.cshtml b/samples/existingWindowsBackend/webfrontend-linux/Views/_ViewStart.cshtml new file mode 100644 index 000000000..a5f10045d --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/Views/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "_Layout"; +} diff --git a/samples/existingWindowsBackend/webfrontend-linux/appsettings.Development.json b/samples/existingWindowsBackend/webfrontend-linux/appsettings.Development.json new file mode 100644 index 000000000..fa8ce71a9 --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/samples/existingWindowsBackend/webfrontend-linux/appsettings.json b/samples/existingWindowsBackend/webfrontend-linux/appsettings.json new file mode 100644 index 000000000..5fff67bac --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Warning" + } + } +} diff --git a/samples/existingWindowsBackend/webfrontend-linux/bundleconfig.json b/samples/existingWindowsBackend/webfrontend-linux/bundleconfig.json new file mode 100644 index 000000000..6d3f9a57a --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/bundleconfig.json @@ -0,0 +1,24 @@ +// Configure bundling and minification for the project. +// More info at https://go.microsoft.com/fwlink/?LinkId=808241 +[ + { + "outputFileName": "wwwroot/css/site.min.css", + // An array of relative input file paths. Globbing patterns supported + "inputFiles": [ + "wwwroot/css/site.css" + ] + }, + { + "outputFileName": "wwwroot/js/site.min.js", + "inputFiles": [ + "wwwroot/js/site.js" + ], + // Optionally specify minification options + "minify": { + "enabled": true, + "renameLocals": true + }, + // Optionally generate .map file + "sourceMap": false + } +] diff --git a/samples/existingWindowsBackend/webfrontend-linux/webfrontend.csproj b/samples/existingWindowsBackend/webfrontend-linux/webfrontend.csproj new file mode 100644 index 000000000..5e8a92ad5 --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/webfrontend.csproj @@ -0,0 +1,12 @@ + + + + netcoreapp2.2 + + + + + + + + diff --git a/samples/existingWindowsBackend/webfrontend-linux/wwwroot/css/site.css b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/css/site.css new file mode 100644 index 000000000..6d0f6e44e --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/css/site.css @@ -0,0 +1,35 @@ +body { + padding-top: 50px; + padding-bottom: 20px; +} + +/* Wrapping element */ +/* Set some basic padding to keep content from hitting the edges */ +.body-content { + padding-left: 15px; + padding-right: 15px; +} + +/* Carousel */ +.carousel-caption p { + font-size: 20px; + line-height: 1.4; +} + +/* Make .svg files in the carousel display properly in older browsers */ +.carousel-inner .item img[src$=".svg"] { + width: 100%; +} + +/* QR code generator */ +#qrCode { + margin: 15px; +} + +/* Hide/rearrange for smaller screens */ +@media screen and (max-width: 767px) { + /* Hide captions */ + .carousel-caption { + display: none; + } +} diff --git a/samples/existingWindowsBackend/webfrontend-linux/wwwroot/css/site.min.css b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/css/site.min.css new file mode 100644 index 000000000..5e93e30ae --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/css/site.min.css @@ -0,0 +1 @@ +body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}.carousel-caption p{font-size:20px;line-height:1.4}.carousel-inner .item img[src$=".svg"]{width:100%}#qrCode{margin:15px}@media screen and (max-width:767px){.carousel-caption{display:none}} \ No newline at end of file diff --git a/samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner1.svg b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner1.svg new file mode 100644 index 000000000..1ab32b60b --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner2.svg b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner2.svg new file mode 100644 index 000000000..9679c604d --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner3.svg b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner3.svg new file mode 100644 index 000000000..9be2c2503 --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner3.svg @@ -0,0 +1 @@ +banner3b \ No newline at end of file diff --git a/samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner4.svg b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner4.svg new file mode 100644 index 000000000..38b3d7cd1 --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/images/banner4.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/samples/existingWindowsBackend/webfrontend-linux/wwwroot/js/site.js b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/js/site.js new file mode 100644 index 000000000..0f3411a45 --- /dev/null +++ b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/js/site.js @@ -0,0 +1 @@ +// Write your JavaScript code. diff --git a/samples/existingWindowsBackend/webfrontend-linux/wwwroot/js/site.min.js b/samples/existingWindowsBackend/webfrontend-linux/wwwroot/js/site.min.js new file mode 100644 index 000000000..e69de29bb