├── .devcontainer ├── dotnet-compliance │ └── devcontainer.json ├── dotnet-docker │ └── devcontainer.json ├── dotnet-feature-flags │ └── devcontainer.json ├── dotnet-kubernetes │ └── devcontainer.json ├── dotnet-observability │ └── devcontainer.json └── dotnet-resiliency │ └── devcontainer.json ├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE-CODE ├── README.md ├── SECURITY.md ├── choose-dev-container.png ├── codespace-with-options.png ├── dotnet-compliance ├── .dockerignore ├── LICENSE.txt ├── README.md ├── docker-compose.yml ├── eShopLite │ ├── DataEntities │ │ ├── DataEntities.csproj │ │ ├── Order.cs │ │ └── Product.cs │ ├── Products │ │ ├── .config │ │ │ └── dotnet-tools.json │ │ ├── Data │ │ │ └── EShopDataContext.cs │ │ ├── Database.db │ │ ├── Database.db-shm │ │ ├── Database.db-wal │ │ ├── Endpoints │ │ │ └── EShopEndpoints.cs │ │ ├── Products.csproj │ │ ├── Products.http │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── wwwroot │ │ │ └── images │ │ │ ├── product1.png │ │ │ ├── product2.png │ │ │ ├── product3.png │ │ │ ├── product4.png │ │ │ ├── product5.png │ │ │ ├── product6.png │ │ │ ├── product7.png │ │ │ ├── product8.png │ │ │ └── product9.png │ ├── Store │ │ ├── Components │ │ │ ├── App.razor │ │ │ ├── Layout │ │ │ │ ├── MainLayout.razor │ │ │ │ ├── MainLayout.razor.css │ │ │ │ ├── NavMenu.razor │ │ │ │ └── NavMenu.razor.css │ │ │ ├── ModalDialog.razor │ │ │ ├── Pages │ │ │ │ ├── Home.razor │ │ │ │ └── Products.razor │ │ │ ├── Routes.razor │ │ │ └── _Imports.razor │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── Services │ │ │ ├── ModalDialogResponse.cs │ │ │ └── ProductService.cs │ │ ├── Store.csproj │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── wwwroot │ │ │ ├── app.css │ │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ │ └── favicon.png │ └── eShopLite.sln └── finished-files │ └── eShopLite │ ├── ComplianceReport │ ├── DataEntities │ │ └── ComplianceReport.json │ └── Store │ │ └── ComplianceReport.json │ ├── DataEntities │ ├── Compliance.cs │ ├── DataEntities.csproj │ ├── Order.cs │ └── Product.cs │ └── Store │ ├── Program.cs │ ├── Services │ └── ProductService.cs │ └── Store.csproj ├── dotnet-docker ├── .dockerignore ├── DataEntities │ ├── DataEntities.csproj │ └── Product.cs ├── LICENSE.txt ├── Products │ ├── .config │ │ └── dotnet-tools.json │ ├── Data │ │ └── ProductDataContext.cs │ ├── Database.db │ ├── Database.db-shm │ ├── Database.db-wal │ ├── Endpoints │ │ └── ProductEndpoints.cs │ ├── Products.csproj │ ├── Products.http │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ └── images │ │ ├── product1.png │ │ ├── product2.png │ │ ├── product3.png │ │ ├── product4.png │ │ ├── product5.png │ │ ├── product6.png │ │ ├── product7.png │ │ ├── product8.png │ │ └── product9.png ├── README.md ├── Store │ ├── Components │ │ ├── App.razor │ │ ├── Layout │ │ │ ├── MainLayout.razor │ │ │ ├── MainLayout.razor.css │ │ │ ├── NavMenu.razor │ │ │ └── NavMenu.razor.css │ │ ├── Pages │ │ │ ├── Home.razor │ │ │ └── Products.razor │ │ ├── Routes.razor │ │ └── _Imports.razor │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Services │ │ └── ProductService.cs │ ├── Store.csproj │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ ├── app.css │ │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── favicon.png ├── docker-compose.yml ├── eShopLite.sln └── finished-files │ ├── Dockerfile │ └── docker-compose.yml ├── dotnet-feature-flags ├── .dockerignore ├── DataEntities │ ├── DataEntities.csproj │ └── Product.cs ├── DockerfileProducts.acr ├── LICENSE.txt ├── Products │ ├── .config │ │ └── dotnet-tools.json │ ├── Data │ │ └── ProductDataContext.cs │ ├── Database.db │ ├── Database.db-shm │ ├── Database.db-wal │ ├── Endpoints │ │ └── ProductEndpoints.cs │ ├── Products.csproj │ ├── Products.http │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ └── images │ │ ├── product1.png │ │ ├── product2.png │ │ ├── product3.png │ │ ├── product4.png │ │ ├── product5.png │ │ ├── product6.png │ │ ├── product7.png │ │ ├── product8.png │ │ └── product9.png ├── README.md ├── Store │ ├── Components │ │ ├── App.razor │ │ ├── Layout │ │ │ ├── MainLayout.razor │ │ │ ├── MainLayout.razor.css │ │ │ ├── NavMenu.razor │ │ │ └── NavMenu.razor.css │ │ ├── Pages │ │ │ ├── Home.razor │ │ │ └── Products.razor │ │ ├── Routes.razor │ │ └── _Imports.razor │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Services │ │ └── ProductService.cs │ ├── Store.csproj │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ ├── app.css │ │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── favicon.png ├── deployment.yml ├── docker-compose.yml ├── eShopLite.sln └── product.yml ├── dotnet-kubernetes ├── .dockerignore ├── DataEntities │ ├── DataEntities.csproj │ └── Product.cs ├── LICENSE.txt ├── Products │ ├── .config │ │ └── dotnet-tools.json │ ├── Data │ │ └── ProductDataContext.cs │ ├── Endpoints │ │ └── ProductEndpoints.cs │ ├── Products.csproj │ ├── Products.http │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ └── images │ │ ├── product1.png │ │ ├── product2.png │ │ ├── product3.png │ │ ├── product4.png │ │ ├── product5.png │ │ ├── product6.png │ │ ├── product7.png │ │ ├── product8.png │ │ └── product9.png ├── README.md ├── Store │ ├── Components │ │ ├── App.razor │ │ ├── Layout │ │ │ ├── MainLayout.razor │ │ │ ├── MainLayout.razor.css │ │ │ ├── NavMenu.razor │ │ │ └── NavMenu.razor.css │ │ ├── Pages │ │ │ ├── Home.razor │ │ │ └── Products.razor │ │ ├── Routes.razor │ │ └── _Imports.razor │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Services │ │ └── ProductService.cs │ ├── Store.csproj │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ ├── app.css │ │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── favicon.png ├── docker-compose.yml ├── eShopLite.sln ├── finished-files │ ├── backend-deploy.yml │ └── frontend-deploy.yml └── k3d.yml ├── dotnet-observability ├── .dockerignore ├── LICENSE.txt ├── README.md ├── docker-compose.yml ├── eShopLite │ ├── DataEntities │ │ ├── DataEntities.csproj │ │ └── Product.cs │ ├── Products │ │ ├── .config │ │ │ └── dotnet-tools.json │ │ ├── Data │ │ │ └── ProductDataContext.cs │ │ ├── Database.db │ │ ├── Database.db-shm │ │ ├── Database.db-wal │ │ ├── Dockerfile │ │ ├── Endpoints │ │ │ └── ProductEndpoints.cs │ │ ├── Products.csproj │ │ ├── Products.http │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── wwwroot │ │ │ └── images │ │ │ ├── product1.png │ │ │ ├── product2.png │ │ │ ├── product3.png │ │ │ ├── product4.png │ │ │ ├── product5.png │ │ │ ├── product6.png │ │ │ ├── product7.png │ │ │ ├── product8.png │ │ │ └── product9.png │ ├── Store │ │ ├── Components │ │ │ ├── App.razor │ │ │ ├── Layout │ │ │ │ ├── MainLayout.razor │ │ │ │ ├── MainLayout.razor.css │ │ │ │ ├── NavMenu.razor │ │ │ │ └── NavMenu.razor.css │ │ │ ├── ModalDialog.razor │ │ │ ├── Pages │ │ │ │ ├── Home.razor │ │ │ │ └── Products.razor │ │ │ ├── Routes.razor │ │ │ └── _Imports.razor │ │ ├── Dockerfile │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── Services │ │ │ ├── ModalDialogResponse.cs │ │ │ └── ProductService.cs │ │ ├── Store.csproj │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── wwwroot │ │ │ ├── app.css │ │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ │ └── favicon.png │ └── eShopLite.sln └── finished-files │ ├── docker-compose.yml │ ├── eShopLite │ ├── DataEntities │ │ ├── DataEntities.csproj │ │ └── Product.cs │ ├── Diagnostics │ │ ├── DiagnosticServiceCollectionExtensions.cs │ │ ├── Diagnostics.csproj │ │ └── Properties │ │ │ └── launchSettings.json │ ├── Products │ │ ├── .config │ │ │ └── dotnet-tools.json │ │ ├── Data │ │ │ └── ProductDataContext.cs │ │ ├── Database.db │ │ ├── Database.db-shm │ │ ├── Database.db-wal │ │ ├── Dockerfile │ │ ├── Endpoints │ │ │ └── ProductEndpoints.cs │ │ ├── Instrumentation.cs │ │ ├── Products.csproj │ │ ├── Products.http │ │ ├── ProductsMetrics.cs │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── wwwroot │ │ │ └── images │ │ │ ├── product1.png │ │ │ ├── product2.png │ │ │ ├── product3.png │ │ │ ├── product4.png │ │ │ ├── product5.png │ │ │ ├── product6.png │ │ │ ├── product7.png │ │ │ ├── product8.png │ │ │ └── product9.png │ ├── Store │ │ ├── Components │ │ │ ├── App.razor │ │ │ ├── Layout │ │ │ │ ├── MainLayout.razor │ │ │ │ ├── MainLayout.razor.css │ │ │ │ ├── NavMenu.razor │ │ │ │ └── NavMenu.razor.css │ │ │ ├── ModalDialog.razor │ │ │ ├── Pages │ │ │ │ ├── Home.razor │ │ │ │ └── Products.razor │ │ │ ├── Routes.razor │ │ │ └── _Imports.razor │ │ ├── Dockerfile │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── Services │ │ │ ├── ModalDialogResponse.cs │ │ │ └── ProductService.cs │ │ ├── Store.csproj │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── wwwroot │ │ │ ├── app.css │ │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ │ └── favicon.png │ └── eShopLite.sln │ ├── grafana │ └── datasource │ │ └── datasource.yml │ └── prometheus │ └── prometheus.yml └── dotnet-resiliency ├── .dockerignore ├── DataEntities ├── DataEntities.csproj └── Product.cs ├── LICENSE.txt ├── Products ├── .config │ └── dotnet-tools.json ├── Data │ └── ProductDataContext.cs ├── Endpoints │ └── ProductEndpoints.cs ├── Products.csproj ├── Products.http ├── Program.cs ├── Properties │ └── launchSettings.json ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ └── images │ ├── product1.png │ ├── product2.png │ ├── product3.png │ ├── product4.png │ ├── product5.png │ ├── product6.png │ ├── product7.png │ ├── product8.png │ └── product9.png ├── README.md ├── Store ├── Components │ ├── App.razor │ ├── Layout │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ ├── Pages │ │ ├── Home.razor │ │ └── Products.razor │ ├── Routes.razor │ └── _Imports.razor ├── Program.cs ├── Properties │ └── launchSettings.json ├── Services │ └── ProductService.cs ├── Store.csproj ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── app.css │ ├── bootstrap │ ├── bootstrap.min.css │ └── bootstrap.min.css.map │ └── favicon.png ├── backend-deploy.yml ├── docker-compose.yml ├── eShopLite.sln ├── finished-files └── Program.cs ├── frontend-deploy.yml └── k3d.yml /.devcontainer/dotnet-compliance/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eShopLite - dotnet-compliance", 3 | "image": "mcr.microsoft.com/devcontainers/dotnet", 4 | "features": { 5 | "ghcr.io/devcontainers/features/dotnet:2": { "version": "8.0"}, 6 | "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {}, 7 | "ghcr.io/devcontainers/features/azure-cli:1": {}, 8 | "ghcr.io/devcontainers/features/docker-from-docker:1.3.1": {}, 9 | "ghcr.io/devcontainers/features/github-cli:1": { "version": "2" } 10 | }, 11 | "customizations": { 12 | "vscode": { 13 | "extensions": [ 14 | "ms-vscode.vscode-node-azure-pack", 15 | "github.vscode-github-actions", 16 | "ms-dotnettools.csdevkit", 17 | "ms-kubernetes-tools.vscode-kubernetes-tools" 18 | ] 19 | } 20 | }, 21 | "forwardPorts": [ 22 | 32000, 23 | 32001 24 | ], 25 | "postCreateCommand": "cd dotnet-compliance/eShopLite && dotnet restore", 26 | "remoteUser": "vscode", 27 | "hostRequirements": { 28 | "memory": "8gb", 29 | "cpus": 4 30 | }, 31 | "portsAttributes": { 32 | "32001": { 33 | "label": "Back End" 34 | }, 35 | "32000": { 36 | "label": "Front End" 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /.devcontainer/dotnet-docker/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eShopLite - dotnet-docker", 3 | "image": "mcr.microsoft.com/devcontainers/dotnet", 4 | "features": { 5 | "ghcr.io/devcontainers/features/dotnet:2": { "version": "8.0"}, 6 | "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {}, 7 | "ghcr.io/devcontainers/features/azure-cli:1": {}, 8 | "ghcr.io/devcontainers/features/docker-from-docker:1.3.1": {}, 9 | "ghcr.io/devcontainers/features/github-cli:1": { "version": "2" } 10 | }, 11 | "customizations": { 12 | "vscode": { 13 | "extensions": [ 14 | "ms-vscode.vscode-node-azure-pack", 15 | "github.vscode-github-actions", 16 | "ms-dotnettools.csdevkit" 17 | ] 18 | } 19 | }, 20 | "forwardPorts": [ 21 | 32000, 22 | 32001 23 | ], 24 | "postCreateCommand": "cd dotnet-docker && dotnet restore", 25 | "remoteUser": "vscode", 26 | "hostRequirements": { 27 | "memory": "8gb", 28 | "cpus": 4 29 | }, 30 | "portsAttributes": { 31 | "32001": { 32 | "label": "Back End" 33 | }, 34 | "32000": { 35 | "label": "Front End" 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.devcontainer/dotnet-feature-flags/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eShopLite - dotnet-feature-flags", 3 | "image": "mcr.microsoft.com/devcontainers/dotnet", 4 | "features": { 5 | "ghcr.io/devcontainers/features/dotnet:2": { "version": "8.0"}, 6 | "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {}, 7 | "ghcr.io/devcontainers/features/azure-cli:1": {}, 8 | "ghcr.io/devcontainers/features/docker-from-docker:1.3.1": {}, 9 | "ghcr.io/devcontainers/features/github-cli:1": { "version": "2" } 10 | }, 11 | "customizations": { 12 | "vscode": { 13 | "extensions": [ 14 | "ms-vscode.vscode-node-azure-pack", 15 | "github.vscode-github-actions", 16 | "ms-dotnettools.csdevkit" 17 | ] 18 | } 19 | }, 20 | "forwardPorts": [ 21 | 32000, 22 | 32001 23 | ], 24 | "postCreateCommand": "cd dotnet-feature-flags && dotnet restore", 25 | "remoteUser": "vscode", 26 | "hostRequirements": { 27 | "memory": "8gb", 28 | "cpus": 4 29 | }, 30 | "portsAttributes": { 31 | "32001": { 32 | "label": "Back End" 33 | }, 34 | "32000": { 35 | "label": "Front End" 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /.devcontainer/dotnet-kubernetes/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eShopLite - dotnet-kubernetes", 3 | "image": "mcr.microsoft.com/devcontainers/dotnet", 4 | "features": { 5 | "ghcr.io/devcontainers/features/dotnet:2": { "version": "8.0"}, 6 | "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {}, 7 | "ghcr.io/devcontainers/features/azure-cli:1": {}, 8 | "ghcr.io/devcontainers/features/docker-from-docker:1.3.1": {}, 9 | "ghcr.io/devcontainers/features/github-cli:1": { "version": "2" } 10 | }, 11 | "customizations": { 12 | "vscode": { 13 | "extensions": [ 14 | "ms-vscode.vscode-node-azure-pack", 15 | "github.vscode-github-actions", 16 | "ms-dotnettools.csdevkit", 17 | "ms-kubernetes-tools.vscode-kubernetes-tools" 18 | ] 19 | } 20 | }, 21 | "forwardPorts": [ 22 | 32000, 23 | 32001 24 | ], 25 | "postCreateCommand": "cd dotnet-kubernetes && dotnet restore", 26 | "remoteUser": "vscode", 27 | "hostRequirements": { 28 | "memory": "8gb", 29 | "cpus": 4 30 | }, 31 | "portsAttributes": { 32 | "32001": { 33 | "label": "Back End" 34 | }, 35 | "32000": { 36 | "label": "Front End" 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /.devcontainer/dotnet-observability/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eShopLite - dotnet-observability", 3 | "image": "mcr.microsoft.com/devcontainers/dotnet", 4 | "features": { 5 | "ghcr.io/devcontainers/features/dotnet:2": { "version": "8.0"}, 6 | "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {}, 7 | "ghcr.io/devcontainers/features/azure-cli:1": {}, 8 | "ghcr.io/devcontainers/features/docker-from-docker:1.3.1": {}, 9 | "ghcr.io/devcontainers/features/github-cli:1": { "version": "2" } 10 | }, 11 | "customizations": { 12 | "vscode": { 13 | "extensions": [ 14 | "ms-vscode.vscode-node-azure-pack", 15 | "github.vscode-github-actions", 16 | "ms-dotnettools.csdevkit", 17 | "ms-kubernetes-tools.vscode-kubernetes-tools" 18 | ] 19 | } 20 | }, 21 | "forwardPorts": [ 22 | 3000, 23 | 9090, 24 | 9411, 25 | 32000, 26 | 32001 27 | ], 28 | "postCreateCommand": "cd dotnet-observability && dotnet restore", 29 | "remoteUser": "vscode", 30 | "hostRequirements": { 31 | "memory": "8gb", 32 | "cpus": 4 33 | }, 34 | "portsAttributes": { 35 | "3000": { 36 | "label": "Grafana" 37 | }, 38 | "9090": { 39 | "label": "Prometheus" 40 | }, 41 | "9411": { 42 | "label": "Zipkin" 43 | }, 44 | "32001": { 45 | "label": "Back End" 46 | }, 47 | "32000": { 48 | "label": "Front End" 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /.devcontainer/dotnet-resiliency/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eShopLite - dotnet-resiliency", 3 | "image": "mcr.microsoft.com/devcontainers/dotnet", 4 | "features": { 5 | "ghcr.io/devcontainers/features/dotnet:2": { "version": "8.0"}, 6 | "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {}, 7 | "ghcr.io/devcontainers/features/azure-cli:1": {}, 8 | "ghcr.io/devcontainers/features/docker-from-docker:1.3.1": {}, 9 | "ghcr.io/devcontainers/features/github-cli:1": { "version": "2" } 10 | }, 11 | "customizations": { 12 | "vscode": { 13 | "extensions": [ 14 | "ms-vscode.vscode-node-azure-pack", 15 | "github.vscode-github-actions", 16 | "ms-dotnettools.csdevkit" 17 | ] 18 | } 19 | }, 20 | "forwardPorts": [ 21 | 32000, 22 | 32001 23 | ], 24 | "postCreateCommand": "cd dotnet-resiliency && dotnet restore", 25 | "remoteUser": "vscode", 26 | "hostRequirements": { 27 | "memory": "8gb", 28 | "cpus": 4 29 | }, 30 | "portsAttributes": { 31 | "32001": { 32 | "label": "Back End" 33 | }, 34 | "32000": { 35 | "label": "Front End" 36 | } 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /LICENSE-CODE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Microsoft Learn for .NET Cloud Native Development 2 | 3 | This repo contains the sample code for all the exercises in the [cloud native learning path for .NET](https://learn.microsoft.com/training/paths/create-microservices-with-dotnet/). 4 | 5 | 1. Select **Code**. 6 | 2. Select the **Codespaces** tab. 7 | 8 | A screenshot showing the New with options menu. 9 | 10 | 4. Select **...** (Codespace respository configuration), then select **+ New with options**. 11 | 5. Select the devcontainer for the module you want. 12 | 13 | A screenshot showing the devcontainer. 14 | 15 | ## Running Locally? 16 | 17 | Make sure to update the appsettings.json for the database to: 18 | 19 | ```json 20 | "ProductsContext": "Data Source=Database.db" 21 | ``` 22 | 23 | It has been configured by default for use in a codespace. -------------------------------------------------------------------------------- /choose-dev-container.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/choose-dev-container.png -------------------------------------------------------------------------------- /codespace-with-options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/codespace-with-options.png -------------------------------------------------------------------------------- /dotnet-compliance/.dockerignore: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /dotnet-compliance/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /dotnet-compliance/README.md: -------------------------------------------------------------------------------- 1 | # eShopLite -------------------------------------------------------------------------------- /dotnet-compliance/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | 5 | frontend: 6 | image: store:latest 7 | environment: 8 | - ProductEndpoint=http://backend:8080 9 | ports: 10 | - "32000:8080" 11 | depends_on: 12 | - backend 13 | backend: 14 | image: products:latest 15 | ports: 16 | - "32001:8080" -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/DataEntities/DataEntities.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/DataEntities/Order.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace DataEntities; 5 | 6 | public class Order 7 | { 8 | [Key] 9 | [JsonPropertyName("id")] 10 | public int Id { get; set; } 11 | 12 | [JsonPropertyName("products")] 13 | public List? Products { get; set; } 14 | 15 | [JsonPropertyName("total")] 16 | public decimal Total { get; set; } 17 | 18 | [JsonPropertyName("customerName")] 19 | public string? CustomerName { get; set; } 20 | 21 | [JsonPropertyName("customerAddress")] 22 | public string? CustomerAddress { get; set; } 23 | } 24 | 25 | [JsonSerializable(typeof(List))] 26 | public sealed partial class OrderSerializerContext : JsonSerializerContext 27 | { 28 | } -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/DataEntities/Product.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace DataEntities; 5 | 6 | public class Product 7 | { 8 | [Key] 9 | [JsonPropertyName("id")] 10 | public int Id { get; set; } 11 | 12 | [JsonPropertyName("name")] 13 | public string? Name { get; set; } 14 | 15 | [JsonPropertyName("description")] 16 | public string? Description { get; set; } 17 | 18 | [JsonPropertyName("price")] 19 | public decimal Price { get; set; } 20 | 21 | [JsonPropertyName("imageUrl")] 22 | public string? ImageUrl { get; set; } 23 | 24 | [JsonPropertyName("stock")] 25 | public int Stock { get; set; } 26 | 27 | [JsonIgnore] 28 | public List? Orders { get; set; } 29 | } 30 | 31 | 32 | [JsonSerializable(typeof(List))] 33 | public sealed partial class ProductSerializerContext : JsonSerializerContext 34 | { 35 | } -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "dotnet-ef": { 6 | "version": "7.0.10", 7 | "commands": [ 8 | "dotnet-ef" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/Database.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-compliance/eShopLite/Products/Database.db -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/Database.db-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-compliance/eShopLite/Products/Database.db-shm -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/Database.db-wal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-compliance/eShopLite/Products/Database.db-wal -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/Products.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | all 21 | runtime; build; native; contentfiles; analyzers; buildtransitive 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/Products.http: -------------------------------------------------------------------------------- 1 | @HostAddress = http://localhost:5228 2 | 3 | GET {{HostAddress}}/api/Product 4 | Accept: application/json 5 | 6 | ### 7 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/Program.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using Microsoft.EntityFrameworkCore; 3 | using Products.Data; 4 | using Products.Endpoints; 5 | 6 | var builder = WebApplication.CreateBuilder(args); 7 | builder.Services.AddDbContext(options => 8 | options.UseSqlite(builder.Configuration.GetConnectionString("ProductsContext") ?? throw new InvalidOperationException("Connection string 'ProductsContext' not found."))); 9 | 10 | builder.Services.AddControllers() 11 | .AddJsonOptions(options => 12 | { 13 | options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve; 14 | }); 15 | 16 | // Add services to the container. 17 | var app = builder.Build(); 18 | 19 | // Configure the HTTP request pipeline. 20 | app.MapProductEndpoints(); 21 | app.MapOrderEndpoints(); 22 | 23 | app.UseStaticFiles(); 24 | 25 | app.CreateDbIfNotExists(); 26 | 27 | app.Run(); 28 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:49179", 8 | "sslPort": 44375 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "launchUrl": "api/Product", 17 | "applicationUrl": "http://localhost:32001", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "https": { 23 | "commandName": "Project", 24 | "dotnetRunMessages": true, 25 | "launchBrowser": true, 26 | "launchUrl": "api/Product", 27 | "applicationUrl": "https://localhost:33001;http://localhost:32001", 28 | "environmentVariables": { 29 | "ASPNETCORE_ENVIRONMENT": "Development" 30 | } 31 | }, 32 | "IIS Express": { 33 | "commandName": "IISExpress", 34 | "launchBrowser": true, 35 | "launchUrl": "api/Product", 36 | "environmentVariables": { 37 | "ASPNETCORE_ENVIRONMENT": "Development" 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "ProductsContext": "Data Source=/home/app/Database.db" 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/wwwroot/images/product1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-compliance/eShopLite/Products/wwwroot/images/product1.png -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/wwwroot/images/product2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-compliance/eShopLite/Products/wwwroot/images/product2.png -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/wwwroot/images/product3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-compliance/eShopLite/Products/wwwroot/images/product3.png -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/wwwroot/images/product4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-compliance/eShopLite/Products/wwwroot/images/product4.png -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/wwwroot/images/product5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-compliance/eShopLite/Products/wwwroot/images/product5.png -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/wwwroot/images/product6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-compliance/eShopLite/Products/wwwroot/images/product6.png -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/wwwroot/images/product7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-compliance/eShopLite/Products/wwwroot/images/product7.png -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/wwwroot/images/product8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-compliance/eShopLite/Products/wwwroot/images/product8.png -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Products/wwwroot/images/product9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-compliance/eShopLite/Products/wwwroot/images/product9.png -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/Components/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | 19 |
20 | An unhandled error has occurred. 21 | Reload 22 | 🗙 23 |
24 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/Components/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 24 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/Components/ModalDialog.razor: -------------------------------------------------------------------------------- 1 | 24 | 25 | @code { 26 | private int QuantityEntered { get; set; } = 1; 27 | [Parameter] public string Title { get; set; } 28 | [Parameter] public string Text { get; set; } 29 | [Parameter] public EventCallback OnClose { get; set; } 30 | private Task ModalCancel() 31 | { 32 | return OnClose.InvokeAsync(new ModalDialogResponse() 33 | { 34 | Confirm = false, 35 | Quantity = 0 36 | }); 37 | } 38 | 39 | private Task ModalOk() 40 | { 41 | return OnClose.InvokeAsync(new ModalDialogResponse() 42 | { 43 | Confirm = true, 44 | Quantity = QuantityEntered 45 | }); 46 | } 47 | } -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/Components/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Home 4 | 5 |

Home

6 | 7 | Welcome to the best e-commerce stocker management platform in the world - eShopLite! 8 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/Components/Routes.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using static Microsoft.AspNetCore.Components.Web.RenderMode 8 | @using Microsoft.JSInterop 9 | @using Store 10 | @using Store.Components -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/Program.cs: -------------------------------------------------------------------------------- 1 | using Store.Components; 2 | using Store.Services; 3 | 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | builder.Services.AddSingleton(); 7 | builder.Services.AddHttpClient(c => 8 | { 9 | var url = builder.Configuration["ProductEndpoint"] ?? throw new InvalidOperationException("ProductEndpoint is not set"); 10 | 11 | c.BaseAddress = new(url); 12 | }); 13 | 14 | // Add services to the container. 15 | builder.Services.AddRazorComponents() 16 | .AddInteractiveServerComponents(); 17 | 18 | // Add redaction 19 | 20 | var app = builder.Build(); 21 | 22 | // Configure the HTTP request pipeline. 23 | if (!app.Environment.IsDevelopment()) 24 | { 25 | app.UseExceptionHandler("/Error", createScopeForErrors: true); 26 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 27 | app.UseHsts(); 28 | } 29 | 30 | app.UseHttpsRedirection(); 31 | 32 | app.UseStaticFiles(); 33 | app.UseAntiforgery(); 34 | 35 | app.MapRazorComponents() 36 | .AddInteractiveServerRenderMode(); 37 | 38 | app.Run(); 39 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:38240", 8 | "sslPort": 44332 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "applicationUrl": "http://localhost:32000", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "https": { 22 | "commandName": "Project", 23 | "dotnetRunMessages": true, 24 | "launchBrowser": true, 25 | "applicationUrl": "https://localhost:33000;http://localhost:32000", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | }, 30 | "IIS Express": { 31 | "commandName": "IISExpress", 32 | "launchBrowser": true, 33 | "environmentVariables": { 34 | "ASPNETCORE_ENVIRONMENT": "Development" 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/Services/ModalDialogResponse.cs: -------------------------------------------------------------------------------- 1 | namespace Store; 2 | 3 | public class ModalDialogResponse 4 | { 5 | public bool Confirm {get; set;} 6 | public int Quantity {get; set;} 7 | } -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/Store.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | preview 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "ProductEndpoint": "http://localhost:32001", 11 | "ProductEndpointHttps": "https://localhost:32001" 12 | } 13 | -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/Store/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-compliance/eShopLite/Store/wwwroot/favicon.png -------------------------------------------------------------------------------- /dotnet-compliance/eShopLite/eShopLite.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34004.107 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataEntities", "DataEntities\DataEntities.csproj", "{E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Products", "Products\Products.csproj", "{3366FB0E-CCF3-4620-924E-F2DA34BC00F8}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Store", "Store\Store.csproj", "{2E156904-6754-43F5-8B27-9B9D6479D9FC}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {F9C7AE25-263B-4A02-9BC0-632370BB1004} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /dotnet-compliance/finished-files/eShopLite/ComplianceReport/Store/ComplianceReport.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "Name": "Store", 4 | "Types": [ 5 | { 6 | "Name": "Store.Services.Log", 7 | "Logging Methods": [ 8 | { 9 | "Name": "LogOrders", 10 | "Parameters": [ 11 | { 12 | "Name": "logger", 13 | "Type": "Microsoft.Extensions.Logging.ILogger", 14 | "File": "C:\\Developer\\mslearn-dotnet-cloudnative\\dotnet-compliance\\eShopLite\\Store\\Services\\ProductService.cs", 15 | "Line": "103" 16 | }, 17 | { 18 | "Name": "order", 19 | "Type": "DataEntities.Order", 20 | "File": "C:\\Developer\\mslearn-dotnet-cloudnative\\dotnet-compliance\\eShopLite\\Store\\Services\\ProductService.cs", 21 | "Line": "103" 22 | } 23 | ] 24 | } 25 | ] 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /dotnet-compliance/finished-files/eShopLite/DataEntities/Compliance.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Compliance.Classification; 2 | using Microsoft.Extensions.Compliance.Redaction; 3 | 4 | #region Data Taxonomy definition 5 | public static class DataClassifications 6 | { 7 | // End User Identifiable Information 8 | public static DataClassification EUIIDataClassification {get;} = new DataClassification("EUIIDataTaxonomy", "EUIIData"); 9 | 10 | // End User Pseudonymous Information 11 | public static DataClassification EUPDataClassification {get;} = new DataClassification("EUPDataTaxonomy", "EUPData"); 12 | } 13 | 14 | public class EUIIDataAttribute : DataClassificationAttribute 15 | { 16 | public EUIIDataAttribute() : base(DataClassifications.EUIIDataClassification) { } 17 | } 18 | 19 | public class EUPDataAttribute : DataClassificationAttribute 20 | { 21 | public EUPDataAttribute() : base(DataClassifications.EUPDataClassification) { } 22 | } 23 | #endregion 24 | 25 | #region Custom Redactor definition 26 | public class EShopCustomRedactor : Redactor 27 | { 28 | private const string Stars = "*****"; 29 | 30 | public override int GetRedactedLength(ReadOnlySpan input) => Stars.Length; 31 | 32 | public override int Redact(ReadOnlySpan source, Span destination) 33 | { 34 | Stars.CopyTo(destination); 35 | return Stars.Length; 36 | } 37 | } 38 | #endregion -------------------------------------------------------------------------------- /dotnet-compliance/finished-files/eShopLite/DataEntities/DataEntities.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | true 8 | $(MSBuildThisFileDirectory)\..\ComplianceReport\DataEntities 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /dotnet-compliance/finished-files/eShopLite/DataEntities/Order.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace DataEntities; 5 | 6 | public class Order 7 | { 8 | [Key] 9 | [EUPData] 10 | [JsonPropertyName("id")] 11 | public int Id { get; set; } 12 | 13 | [JsonPropertyName("products")] 14 | public List? Products { get; set; } 15 | 16 | [JsonPropertyName("total")] 17 | public decimal Total { get; set; } 18 | 19 | [EUIIData] 20 | [JsonPropertyName("customerName")] 21 | public string? CustomerName { get; set; } 22 | 23 | [EUIIData] 24 | [JsonPropertyName("customerAddress")] 25 | public string? CustomerAddress { get; set; } 26 | } 27 | 28 | [JsonSerializable(typeof(List))] 29 | public sealed partial class OrderSerializerContext : JsonSerializerContext 30 | { 31 | } -------------------------------------------------------------------------------- /dotnet-compliance/finished-files/eShopLite/DataEntities/Product.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace DataEntities; 5 | 6 | public class Product 7 | { 8 | [Key] 9 | [EUPData] 10 | [JsonPropertyName("id")] 11 | public int Id { get; set; } 12 | 13 | [JsonPropertyName("name")] 14 | public string? Name { get; set; } 15 | 16 | [JsonPropertyName("description")] 17 | public string? Description { get; set; } 18 | 19 | [JsonPropertyName("price")] 20 | public decimal Price { get; set; } 21 | 22 | [JsonPropertyName("imageUrl")] 23 | public string? ImageUrl { get; set; } 24 | 25 | [JsonPropertyName("stock")] 26 | public int Stock { get; set; } 27 | 28 | [JsonIgnore] 29 | public List? Orders { get; set; } 30 | } 31 | 32 | 33 | [JsonSerializable(typeof(List))] 34 | public sealed partial class ProductSerializerContext : JsonSerializerContext 35 | { 36 | } -------------------------------------------------------------------------------- /dotnet-compliance/finished-files/eShopLite/Store/Program.cs: -------------------------------------------------------------------------------- 1 | using Store.Components; 2 | using Store.Services; 3 | using Microsoft.Extensions.Compliance.Classification; 4 | using Microsoft.Extensions.Compliance.Redaction; 5 | 6 | var builder = WebApplication.CreateBuilder(args); 7 | 8 | builder.Services.AddSingleton(); 9 | builder.Services.AddHttpClient(c => 10 | { 11 | var url = builder.Configuration["ProductEndpoint"] ?? throw new InvalidOperationException("ProductEndpoint is not set"); 12 | 13 | c.BaseAddress = new(url); 14 | }); 15 | 16 | // Add services to the container. 17 | builder.Services.AddRazorComponents() 18 | .AddInteractiveServerComponents(); 19 | 20 | // Add redaction 21 | builder.Services.AddRedaction(configure => 22 | { 23 | configure.SetRedactor(new DataClassificationSet(DataClassifications.EUPDataClassification)); 24 | configure.SetRedactor(new DataClassificationSet(DataClassifications.EUIIDataClassification)); 25 | }); 26 | 27 | builder.Services.AddLogging(logging => 28 | { 29 | logging.EnableRedaction(); 30 | logging.AddJsonConsole(); //Enable structure logs on the console to view the redacted data. 31 | }); 32 | 33 | var app = builder.Build(); 34 | 35 | // Configure the HTTP request pipeline. 36 | if (!app.Environment.IsDevelopment()) 37 | { 38 | app.UseExceptionHandler("/Error", createScopeForErrors: true); 39 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 40 | app.UseHsts(); 41 | } 42 | 43 | app.UseHttpsRedirection(); 44 | 45 | app.UseStaticFiles(); 46 | app.UseAntiforgery(); 47 | 48 | app.MapRazorComponents() 49 | .AddInteractiveServerRenderMode(); 50 | 51 | app.Run(); 52 | -------------------------------------------------------------------------------- /dotnet-compliance/finished-files/eShopLite/Store/Store.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | preview 8 | true 9 | $(MSBuildThisFileDirectory)\..\ComplianceReport\Store 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /dotnet-docker/.dockerignore: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /dotnet-docker/DataEntities/DataEntities.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /dotnet-docker/DataEntities/Product.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace DataEntities; 4 | 5 | public class Product 6 | { 7 | [JsonPropertyName("id")] 8 | public int Id { get; set; } 9 | 10 | [JsonPropertyName("name")] 11 | public string? Name { get; set; } 12 | 13 | [JsonPropertyName("description")] 14 | public string? Description { get; set; } 15 | 16 | [JsonPropertyName("price")] 17 | public decimal Price { get; set; } 18 | 19 | [JsonPropertyName("imageUrl")] 20 | public string? ImageUrl { get; set; } 21 | } 22 | 23 | 24 | [JsonSerializable(typeof(List))] 25 | public sealed partial class ProductSerializerContext : JsonSerializerContext 26 | { 27 | } -------------------------------------------------------------------------------- /dotnet-docker/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /dotnet-docker/Products/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "dotnet-ef": { 6 | "version": "7.0.10", 7 | "commands": [ 8 | "dotnet-ef" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-docker/Products/Database.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/Products/Database.db -------------------------------------------------------------------------------- /dotnet-docker/Products/Database.db-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/Products/Database.db-shm -------------------------------------------------------------------------------- /dotnet-docker/Products/Database.db-wal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/Products/Database.db-wal -------------------------------------------------------------------------------- /dotnet-docker/Products/Products.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | all 21 | runtime; build; native; contentfiles; analyzers; buildtransitive 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /dotnet-docker/Products/Products.http: -------------------------------------------------------------------------------- 1 | @HostAddress = http://localhost:5228 2 | 3 | GET {{HostAddress}}/api/Product 4 | Accept: application/json 5 | 6 | ### 7 | -------------------------------------------------------------------------------- /dotnet-docker/Products/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Products.Data; 3 | using Products.Endpoints; 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | builder.Services.AddDbContext(options => 7 | options.UseSqlite(builder.Configuration.GetConnectionString("ProductsContext") ?? throw new InvalidOperationException("Connection string 'ProductsContext' not found."))); 8 | 9 | // Add services to the container. 10 | var app = builder.Build(); 11 | 12 | // Configure the HTTP request pipeline. 13 | app.MapProductEndpoints(); 14 | 15 | app.UseStaticFiles(); 16 | 17 | app.CreateDbIfNotExists(); 18 | 19 | app.Run(); 20 | -------------------------------------------------------------------------------- /dotnet-docker/Products/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:49179", 8 | "sslPort": 44375 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "launchUrl": "api/Product", 17 | "applicationUrl": "http://localhost:5228", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "https": { 23 | "commandName": "Project", 24 | "dotnetRunMessages": true, 25 | "launchBrowser": true, 26 | "launchUrl": "api/Product", 27 | "applicationUrl": "https://localhost:7130;http://localhost:5228", 28 | "environmentVariables": { 29 | "ASPNETCORE_ENVIRONMENT": "Development" 30 | } 31 | }, 32 | "IIS Express": { 33 | "commandName": "IISExpress", 34 | "launchBrowser": true, 35 | "launchUrl": "api/Product", 36 | "environmentVariables": { 37 | "ASPNETCORE_ENVIRONMENT": "Development" 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dotnet-docker/Products/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-docker/Products/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "ProductsContext": "Data Source=/home/app/Database.db" 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-docker/Products/wwwroot/images/product1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/Products/wwwroot/images/product1.png -------------------------------------------------------------------------------- /dotnet-docker/Products/wwwroot/images/product2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/Products/wwwroot/images/product2.png -------------------------------------------------------------------------------- /dotnet-docker/Products/wwwroot/images/product3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/Products/wwwroot/images/product3.png -------------------------------------------------------------------------------- /dotnet-docker/Products/wwwroot/images/product4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/Products/wwwroot/images/product4.png -------------------------------------------------------------------------------- /dotnet-docker/Products/wwwroot/images/product5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/Products/wwwroot/images/product5.png -------------------------------------------------------------------------------- /dotnet-docker/Products/wwwroot/images/product6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/Products/wwwroot/images/product6.png -------------------------------------------------------------------------------- /dotnet-docker/Products/wwwroot/images/product7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/Products/wwwroot/images/product7.png -------------------------------------------------------------------------------- /dotnet-docker/Products/wwwroot/images/product8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/Products/wwwroot/images/product8.png -------------------------------------------------------------------------------- /dotnet-docker/Products/wwwroot/images/product9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/Products/wwwroot/images/product9.png -------------------------------------------------------------------------------- /dotnet-docker/README.md: -------------------------------------------------------------------------------- 1 | # eShopLite -------------------------------------------------------------------------------- /dotnet-docker/Store/Components/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /dotnet-docker/Store/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | 19 |
20 | An unhandled error has occurred. 21 | Reload 22 | 🗙 23 |
24 | -------------------------------------------------------------------------------- /dotnet-docker/Store/Components/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 24 | -------------------------------------------------------------------------------- /dotnet-docker/Store/Components/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Home 4 | 5 |

Home

6 | 7 | Welcome to the best e-commerce platform in the world - eShopLite! 8 | -------------------------------------------------------------------------------- /dotnet-docker/Store/Components/Pages/Products.razor: -------------------------------------------------------------------------------- 1 | @page "/products" 2 | @using DataEntities 3 | @using Store.Services 4 | @inject ProductService ProductService 5 | @inject IConfiguration Configuration 6 | @attribute [StreamRendering(true)] 7 | 8 | Products 9 | 10 |

Products

11 | 12 |

Here are some of our amazing outdoor products that you can purchase.

13 | 14 | @if (products == null) 15 | { 16 |

Loading...

17 | } 18 | else 19 | { 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | @foreach (var product in products) 31 | { 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | } 40 | 41 |
ImageNameDescriptionPrice
@product.Name@product.Description@product.Price
42 | } 43 | 44 | @code { 45 | private List? products; 46 | 47 | protected override async Task OnInitializedAsync() 48 | { 49 | // Simulate asynchronous loading to demonstrate streaming rendering 50 | await Task.Delay(500); 51 | products = await ProductService.GetProducts(); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /dotnet-docker/Store/Components/Routes.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /dotnet-docker/Store/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.JSInterop 8 | @using Store 9 | @using Store.Components 10 | -------------------------------------------------------------------------------- /dotnet-docker/Store/Program.cs: -------------------------------------------------------------------------------- 1 | using Store.Components; 2 | using Store.Services; 3 | 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | builder.Services.AddSingleton(); 7 | builder.Services.AddHttpClient(c => 8 | { 9 | var url = builder.Configuration["ProductEndpoint"] ?? throw new InvalidOperationException("ProductEndpoint is not set"); 10 | 11 | c.BaseAddress = new(url); 12 | }); 13 | 14 | // Add services to the container. 15 | builder.Services.AddRazorComponents() 16 | .AddInteractiveServerComponents(); 17 | 18 | var app = builder.Build(); 19 | 20 | // Configure the HTTP request pipeline. 21 | if (!app.Environment.IsDevelopment()) 22 | { 23 | app.UseExceptionHandler("/Error", createScopeForErrors: true); 24 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 25 | app.UseHsts(); 26 | } 27 | 28 | app.UseHttpsRedirection(); 29 | 30 | app.UseStaticFiles(); 31 | app.UseAntiforgery(); 32 | 33 | app.MapRazorComponents() 34 | .AddInteractiveServerRenderMode(); 35 | 36 | app.Run(); 37 | -------------------------------------------------------------------------------- /dotnet-docker/Store/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:38240", 8 | "sslPort": 44332 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "applicationUrl": "http://localhost:5158", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "https": { 22 | "commandName": "Project", 23 | "dotnetRunMessages": true, 24 | "launchBrowser": true, 25 | "applicationUrl": "https://localhost:7085;http://localhost:5158", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | }, 30 | "IIS Express": { 31 | "commandName": "IISExpress", 32 | "launchBrowser": true, 33 | "environmentVariables": { 34 | "ASPNETCORE_ENVIRONMENT": "Development" 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /dotnet-docker/Store/Services/ProductService.cs: -------------------------------------------------------------------------------- 1 | using DataEntities; 2 | using System.Text.Json; 3 | 4 | namespace Store.Services; 5 | 6 | public class ProductService 7 | { 8 | HttpClient httpClient; 9 | private readonly ILogger _logger; 10 | 11 | public ProductService(HttpClient httpClient, ILogger logger) 12 | { 13 | _logger = logger; 14 | this.httpClient = httpClient; 15 | } 16 | public async Task> GetProducts() 17 | { 18 | List? products = null; 19 | try 20 | { 21 | var response = await httpClient.GetAsync("/api/product"); 22 | var responseText = await response.Content.ReadAsStringAsync(); 23 | 24 | _logger.LogInformation($"Http status code: {response.StatusCode}"); 25 | _logger.LogInformation($"Http response content: {responseText}"); 26 | 27 | if (response.IsSuccessStatusCode) 28 | { 29 | var options = new JsonSerializerOptions 30 | { 31 | PropertyNameCaseInsensitive = true 32 | }; 33 | 34 | products = await response.Content.ReadFromJsonAsync(ProductSerializerContext.Default.ListProduct); 35 | } 36 | } 37 | catch (Exception ex) 38 | { 39 | _logger.LogError(ex, "Error during GetProducts."); 40 | } 41 | 42 | return products ?? new List(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /dotnet-docker/Store/Store.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | preview 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /dotnet-docker/Store/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-docker/Store/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "ProductEndpoint": "http://orange-fishstick-5444qv4jxq5h77qp-32001.app.github.dev", 11 | "ProductEndpointHttps": "https://orange-fishstick-5444qv4jxq5h77qp-32001.app.github.dev/" 12 | } 13 | -------------------------------------------------------------------------------- /dotnet-docker/Store/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/Store/wwwroot/favicon.png -------------------------------------------------------------------------------- /dotnet-docker/docker-compose.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-docker/docker-compose.yml -------------------------------------------------------------------------------- /dotnet-docker/eShopLite.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34004.107 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataEntities", "DataEntities\DataEntities.csproj", "{E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Products", "Products\Products.csproj", "{3366FB0E-CCF3-4620-924E-F2DA34BC00F8}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Store", "Store\Store.csproj", "{2E156904-6754-43F5-8B27-9B9D6479D9FC}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {F9C7AE25-263B-4A02-9BC0-632370BB1004} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /dotnet-docker/finished-files/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build 2 | 3 | WORKDIR /DataEntities 4 | COPY "DataEntities/DataEntities.csproj" . 5 | RUN dotnet restore 6 | COPY "DataEntities" . 7 | RUN dotnet publish -c release -o /app 8 | 9 | WORKDIR /src 10 | COPY Products/Products.csproj . 11 | RUN dotnet restore 12 | COPY Products . 13 | RUN dotnet publish -c release -o /app 14 | 15 | FROM mcr.microsoft.com/dotnet/aspnet:8.0 16 | WORKDIR /app 17 | EXPOSE 80 18 | EXPOSE 443 19 | COPY --from=build /app . 20 | ENTRYPOINT ["dotnet", "Products.dll"] -------------------------------------------------------------------------------- /dotnet-docker/finished-files/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | 5 | frontend: 6 | image: store:latest 7 | environment: 8 | - ProductEndpoint=http://backend:8080 9 | ports: 10 | - "32000:8080" 11 | depends_on: 12 | - backend 13 | backend: 14 | image: products:latest 15 | ports: 16 | - "32001:8080" -------------------------------------------------------------------------------- /dotnet-feature-flags/.dockerignore: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /dotnet-feature-flags/DataEntities/DataEntities.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /dotnet-feature-flags/DataEntities/Product.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace DataEntities; 4 | 5 | public class Product 6 | { 7 | [JsonPropertyName("id")] 8 | public int Id { get; set; } 9 | 10 | [JsonPropertyName("name")] 11 | public string? Name { get; set; } 12 | 13 | [JsonPropertyName("description")] 14 | public string? Description { get; set; } 15 | 16 | [JsonPropertyName("price")] 17 | public decimal Price { get; set; } 18 | 19 | [JsonPropertyName("imageUrl")] 20 | public string? ImageUrl { get; set; } 21 | } 22 | 23 | 24 | [JsonSerializable(typeof(List))] 25 | public sealed partial class ProductSerializerContext : JsonSerializerContext 26 | { 27 | } -------------------------------------------------------------------------------- /dotnet-feature-flags/DockerfileProducts.acr: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build 2 | 3 | WORKDIR /DataEntities 4 | COPY DataEntities/DataEntities.csproj . 5 | RUN dotnet restore 6 | COPY DataEntities . 7 | RUN dotnet publish -c release -o /app 8 | 9 | WORKDIR /src 10 | COPY Products/Products.csproj . 11 | RUN dotnet restore 12 | COPY Products . 13 | RUN dotnet publish -c release -o /app 14 | 15 | FROM mcr.microsoft.com/dotnet/aspnet:8.0 16 | WORKDIR /app 17 | EXPOSE 80 18 | EXPOSE 443 19 | COPY --from=build /app . 20 | ENTRYPOINT ["dotnet", "Products.dll"] -------------------------------------------------------------------------------- /dotnet-feature-flags/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "dotnet-ef": { 6 | "version": "7.0.10", 7 | "commands": [ 8 | "dotnet-ef" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/Database.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-feature-flags/Products/Database.db -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/Database.db-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-feature-flags/Products/Database.db-shm -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/Database.db-wal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-feature-flags/Products/Database.db-wal -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/Products.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | all 21 | runtime; build; native; contentfiles; analyzers; buildtransitive 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/Products.http: -------------------------------------------------------------------------------- 1 | @HostAddress = http://localhost:5228 2 | 3 | GET {{HostAddress}}/api/Product 4 | Accept: application/json 5 | 6 | ### 7 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Products.Data; 3 | using Products.Endpoints; 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | builder.Services.AddDbContext(options => 7 | options.UseSqlite(builder.Configuration.GetConnectionString("ProductsContext") ?? throw new InvalidOperationException("Connection string 'ProductsContext' not found."))); 8 | 9 | // Add services to the container. 10 | var app = builder.Build(); 11 | 12 | // Configure the HTTP request pipeline. 13 | app.MapProductEndpoints(); 14 | 15 | app.UseStaticFiles(); 16 | 17 | app.CreateDbIfNotExists(); 18 | 19 | app.Run(); 20 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:49179", 8 | "sslPort": 44375 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "launchUrl": "api/Product", 17 | "applicationUrl": "http://localhost:5228", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "https": { 23 | "commandName": "Project", 24 | "dotnetRunMessages": true, 25 | "launchBrowser": true, 26 | "launchUrl": "api/Product", 27 | "applicationUrl": "https://localhost:7130;http://localhost:5228", 28 | "environmentVariables": { 29 | "ASPNETCORE_ENVIRONMENT": "Development" 30 | } 31 | }, 32 | "IIS Express": { 33 | "commandName": "IISExpress", 34 | "launchBrowser": true, 35 | "launchUrl": "api/Product", 36 | "environmentVariables": { 37 | "ASPNETCORE_ENVIRONMENT": "Development" 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "ProductsContext": "Data Source=/home/app/Database.db" 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/wwwroot/images/product1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-feature-flags/Products/wwwroot/images/product1.png -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/wwwroot/images/product2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-feature-flags/Products/wwwroot/images/product2.png -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/wwwroot/images/product3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-feature-flags/Products/wwwroot/images/product3.png -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/wwwroot/images/product4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-feature-flags/Products/wwwroot/images/product4.png -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/wwwroot/images/product5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-feature-flags/Products/wwwroot/images/product5.png -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/wwwroot/images/product6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-feature-flags/Products/wwwroot/images/product6.png -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/wwwroot/images/product7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-feature-flags/Products/wwwroot/images/product7.png -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/wwwroot/images/product8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-feature-flags/Products/wwwroot/images/product8.png -------------------------------------------------------------------------------- /dotnet-feature-flags/Products/wwwroot/images/product9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-feature-flags/Products/wwwroot/images/product9.png -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/Components/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | 19 |
20 | An unhandled error has occurred. 21 | Reload 22 | 🗙 23 |
24 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/Components/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 24 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/Components/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Home 4 | 5 |

Home

6 | 7 | Welcome to the best e-commerce platform in the world - eShopLite! 8 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/Components/Pages/Products.razor: -------------------------------------------------------------------------------- 1 | @page "/products" 2 | @using DataEntities 3 | @using Store.Services 4 | @inject ProductService ProductService 5 | @inject IConfiguration Configuration 6 | @attribute [StreamRendering(true)] 7 | 8 | @inject ILogger Logger 9 | @using Microsoft.Extensions.Configuration 10 | @inject IConfiguration Configuration 11 | 12 | Products 13 | 14 |

Products

15 | 16 |

Here are some of our amazing outdoor products that you can purchase.

17 | 18 | @if (products == null) 19 | { 20 |

Loading...

21 | } 22 | else if (products.Count == 0) { 23 |

There is a problem loading our products. Please try again later.

24 | } 25 | else 26 | { 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | @foreach (var product in products) 38 | { 39 | 40 | 41 | 42 | 43 | 44 | 45 | } 46 | 47 |
ImageNameDescriptionPrice
@product.Name@product.Description@product.Price
48 | } 49 | 50 | @code { 51 | private List? products; 52 | 53 | protected override async Task OnInitializedAsync() 54 | { 55 | // Simulate asynchronous loading to demonstrate streaming rendering 56 | await Task.Delay(500); 57 | products = await ProductService.GetProducts(); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/Components/Routes.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.JSInterop 8 | @using Store 9 | @using Store.Components 10 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/Program.cs: -------------------------------------------------------------------------------- 1 | using Store.Components; 2 | using Store.Services; 3 | 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | 7 | // Retrieve the connection string 8 | 9 | 10 | // Load configuration from Azure App Configuration 11 | 12 | 13 | // Register the Feature Management library's services 14 | 15 | builder.Services.AddSingleton(); 16 | builder.Services.AddHttpClient(c => 17 | { 18 | var url = builder.Configuration["ProductEndpoint"] ?? throw new InvalidOperationException("ProductEndpoint is not set"); 19 | 20 | c.BaseAddress = new(url); 21 | }); 22 | 23 | // Add services to the container. 24 | builder.Services.AddRazorComponents() 25 | .AddInteractiveServerComponents(); 26 | 27 | var app = builder.Build(); 28 | 29 | // Configure the HTTP request pipeline. 30 | if (!app.Environment.IsDevelopment()) 31 | { 32 | app.UseExceptionHandler("/Error", createScopeForErrors: true); 33 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 34 | app.UseHsts(); 35 | } 36 | 37 | app.UseHttpsRedirection(); 38 | 39 | app.UseStaticFiles(); 40 | app.UseAntiforgery(); 41 | 42 | app.MapRazorComponents() 43 | .AddInteractiveServerRenderMode(); 44 | 45 | 46 | // Add the App Configuration middleware 47 | 48 | app.Run(); 49 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:38240", 8 | "sslPort": 44332 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "applicationUrl": "http://localhost:5158", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "https": { 22 | "commandName": "Project", 23 | "dotnetRunMessages": true, 24 | "launchBrowser": true, 25 | "applicationUrl": "https://localhost:7085;http://localhost:5158", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | }, 30 | "IIS Express": { 31 | "commandName": "IISExpress", 32 | "launchBrowser": true, 33 | "environmentVariables": { 34 | "ASPNETCORE_ENVIRONMENT": "Development" 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/Services/ProductService.cs: -------------------------------------------------------------------------------- 1 | using DataEntities; 2 | using System.Text.Json; 3 | 4 | namespace Store.Services; 5 | 6 | public class ProductService 7 | { 8 | HttpClient httpClient; 9 | private readonly ILogger _logger; 10 | 11 | public ProductService(HttpClient httpClient, ILogger logger) 12 | { 13 | _logger = logger; 14 | this.httpClient = httpClient; 15 | } 16 | public async Task> GetProducts() 17 | { 18 | List? products = null; 19 | try 20 | { 21 | var response = await httpClient.GetAsync("/api/Product"); 22 | var responseText = await response.Content.ReadAsStringAsync(); 23 | 24 | _logger.LogInformation($"Http status code: {response.StatusCode}"); 25 | _logger.LogInformation($"Http response content: {responseText}"); 26 | 27 | if (response.IsSuccessStatusCode) 28 | { 29 | var options = new JsonSerializerOptions 30 | { 31 | PropertyNameCaseInsensitive = true 32 | }; 33 | 34 | products = await response.Content.ReadFromJsonAsync(ProductSerializerContext.Default.ListProduct); 35 | } 36 | } 37 | catch (Exception ex) 38 | { 39 | _logger.LogError(ex, "Error during GetProducts."); 40 | } 41 | 42 | return products ?? new List(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/Store.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | preview 8 | e2714fab-77f1-459a-9fc4-f41379915f0b 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "ProductEndpoint": "http://localhost:32001", 11 | "ProductEndpointHttps": "https://localhost:32001", 12 | "ConnectionStrings:AppConfig": "[PASTE IN YOUR CREDENTIALS HERE]" 13 | } 14 | -------------------------------------------------------------------------------- /dotnet-feature-flags/Store/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-feature-flags/Store/wwwroot/favicon.png -------------------------------------------------------------------------------- /dotnet-feature-flags/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | 5 | frontend: 6 | image: store:latest 7 | environment: 8 | - ProductEndpoint=http://backend:8080 9 | - ConnectionStrings:AppConfig=[PASTE CONNECTION STRING HERE] 10 | ports: 11 | - "32000:8080" 12 | depends_on: 13 | - backend 14 | backend: 15 | image: products:latest 16 | ports: 17 | - "32001:8080" -------------------------------------------------------------------------------- /dotnet-feature-flags/eShopLite.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34004.107 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataEntities", "DataEntities\DataEntities.csproj", "{E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Products", "Products\Products.csproj", "{3366FB0E-CCF3-4620-924E-F2DA34BC00F8}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Store", "Store\Store.csproj", "{2E156904-6754-43F5-8B27-9B9D6479D9FC}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {F9C7AE25-263B-4A02-9BC0-632370BB1004} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /dotnet-feature-flags/product.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: productservice 5 | spec: 6 | selector: # Define the wrapping strategy 7 | matchLabels: # Match all pods with the defined labels 8 | app: productservice # Labels follow the `name: value` template 9 | template: # This is the template of the pod inside the deployment 10 | metadata: 11 | labels: 12 | app: productservice 13 | spec: 14 | nodeSelector: 15 | kubernetes.io/os: linux 16 | containers: 17 | - image: acseshop1680758337.azurecr.io/productservice:v1 18 | name: productservice 19 | resources: 20 | requests: 21 | cpu: 100m 22 | memory: 128Mi 23 | limits: 24 | cpu: 250m 25 | memory: 256Mi 26 | ports: 27 | - containerPort: 8080 28 | name: http 29 | -------------------------------------------------------------------------------- /dotnet-kubernetes/.dockerignore: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /dotnet-kubernetes/DataEntities/DataEntities.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /dotnet-kubernetes/DataEntities/Product.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace DataEntities; 4 | 5 | public class Product 6 | { 7 | [JsonPropertyName("id")] 8 | public int Id { get; set; } 9 | 10 | [JsonPropertyName("name")] 11 | public string? Name { get; set; } 12 | 13 | [JsonPropertyName("description")] 14 | public string? Description { get; set; } 15 | 16 | [JsonPropertyName("price")] 17 | public decimal Price { get; set; } 18 | 19 | [JsonPropertyName("imageUrl")] 20 | public string? ImageUrl { get; set; } 21 | } 22 | 23 | 24 | [JsonSerializable(typeof(List))] 25 | public sealed partial class ProductSerializerContext : JsonSerializerContext 26 | { 27 | } -------------------------------------------------------------------------------- /dotnet-kubernetes/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "dotnet-ef": { 6 | "version": "7.0.10", 7 | "commands": [ 8 | "dotnet-ef" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/Products.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | all 21 | runtime; build; native; contentfiles; analyzers; buildtransitive 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/Products.http: -------------------------------------------------------------------------------- 1 | @HostAddress = http://localhost:5228 2 | 3 | GET {{HostAddress}}/api/Product 4 | Accept: application/json 5 | 6 | ### 7 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Products.Data; 3 | using Products.Endpoints; 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | builder.Services.AddDbContext(options => 7 | options.UseSqlite(builder.Configuration.GetConnectionString("ProductsContext") ?? throw new InvalidOperationException("Connection string 'ProductsContext' not found."))); 8 | 9 | // Add services to the container. 10 | var app = builder.Build(); 11 | 12 | // Configure the HTTP request pipeline. 13 | app.MapProductEndpoints(); 14 | 15 | app.UseStaticFiles(); 16 | 17 | app.CreateDbIfNotExists(); 18 | 19 | app.Run(); 20 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:49179", 8 | "sslPort": 44375 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "launchUrl": "api/Product", 17 | "applicationUrl": "http://localhost:5228", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "https": { 23 | "commandName": "Project", 24 | "dotnetRunMessages": true, 25 | "launchBrowser": true, 26 | "launchUrl": "api/Product", 27 | "applicationUrl": "https://localhost:7130;http://localhost:5228", 28 | "environmentVariables": { 29 | "ASPNETCORE_ENVIRONMENT": "Development" 30 | } 31 | }, 32 | "IIS Express": { 33 | "commandName": "IISExpress", 34 | "launchBrowser": true, 35 | "launchUrl": "api/Product", 36 | "environmentVariables": { 37 | "ASPNETCORE_ENVIRONMENT": "Development" 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "ProductsContext": "Data Source=/home/app/Database.db" 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/wwwroot/images/product1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-kubernetes/Products/wwwroot/images/product1.png -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/wwwroot/images/product2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-kubernetes/Products/wwwroot/images/product2.png -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/wwwroot/images/product3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-kubernetes/Products/wwwroot/images/product3.png -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/wwwroot/images/product4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-kubernetes/Products/wwwroot/images/product4.png -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/wwwroot/images/product5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-kubernetes/Products/wwwroot/images/product5.png -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/wwwroot/images/product6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-kubernetes/Products/wwwroot/images/product6.png -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/wwwroot/images/product7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-kubernetes/Products/wwwroot/images/product7.png -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/wwwroot/images/product8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-kubernetes/Products/wwwroot/images/product8.png -------------------------------------------------------------------------------- /dotnet-kubernetes/Products/wwwroot/images/product9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-kubernetes/Products/wwwroot/images/product9.png -------------------------------------------------------------------------------- /dotnet-kubernetes/README.md: -------------------------------------------------------------------------------- 1 | # eShopLite -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/Components/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | 19 |
20 | An unhandled error has occurred. 21 | Reload 22 | 🗙 23 |
24 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/Components/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 24 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/Components/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Home 4 | 5 |

Home

6 | 7 | Welcome to the best e-commerce platform in the world - eShopLite! 8 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/Components/Pages/Products.razor: -------------------------------------------------------------------------------- 1 | @page "/products" 2 | @using DataEntities 3 | @using Store.Services 4 | @inject ProductService ProductService 5 | @inject IConfiguration Configuration 6 | @attribute [StreamRendering(true)] 7 | 8 | Products 9 | 10 |

Products

11 | 12 |

Here are some of our amazing outdoor products that you can purchase.

13 | 14 | @if (products == null) 15 | { 16 |

Loading...

17 | } 18 | else 19 | { 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | @foreach (var product in products) 31 | { 32 | 33 | 34 | 35 | 36 | 37 | 38 | } 39 | 40 |
ImageNameDescriptionPrice
@product.Name@product.Description@product.Price
41 | } 42 | 43 | @code { 44 | private List? products; 45 | 46 | protected override async Task OnInitializedAsync() 47 | { 48 | // Simulate asynchronous loading to demonstrate streaming rendering 49 | await Task.Delay(500); 50 | products = await ProductService.GetProducts(); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/Components/Routes.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.JSInterop 8 | @using Store 9 | @using Store.Components 10 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/Program.cs: -------------------------------------------------------------------------------- 1 | using Store.Components; 2 | using Store.Services; 3 | 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | builder.Services.AddSingleton(); 7 | builder.Services.AddHttpClient(c => 8 | { 9 | var url = builder.Configuration["ProductEndpoint"] ?? throw new InvalidOperationException("ProductEndpoint is not set"); 10 | 11 | c.BaseAddress = new(url); 12 | }); 13 | 14 | // Add services to the container. 15 | builder.Services.AddRazorComponents() 16 | .AddInteractiveServerComponents(); 17 | 18 | var app = builder.Build(); 19 | 20 | // Configure the HTTP request pipeline. 21 | if (!app.Environment.IsDevelopment()) 22 | { 23 | app.UseExceptionHandler("/Error", createScopeForErrors: true); 24 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 25 | app.UseHsts(); 26 | } 27 | 28 | app.UseHttpsRedirection(); 29 | 30 | app.UseStaticFiles(); 31 | app.UseAntiforgery(); 32 | 33 | app.MapRazorComponents() 34 | .AddInteractiveServerRenderMode(); 35 | 36 | app.Run(); 37 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:38240", 8 | "sslPort": 44332 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "applicationUrl": "http://localhost:5158", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "https": { 22 | "commandName": "Project", 23 | "dotnetRunMessages": true, 24 | "launchBrowser": true, 25 | "applicationUrl": "https://localhost:7085;http://localhost:5158", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | }, 30 | "IIS Express": { 31 | "commandName": "IISExpress", 32 | "launchBrowser": true, 33 | "environmentVariables": { 34 | "ASPNETCORE_ENVIRONMENT": "Development" 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/Services/ProductService.cs: -------------------------------------------------------------------------------- 1 | using DataEntities; 2 | using System.Text.Json; 3 | 4 | namespace Store.Services; 5 | 6 | public class ProductService 7 | { 8 | HttpClient httpClient; 9 | private readonly ILogger _logger; 10 | 11 | public ProductService(HttpClient httpClient, ILogger logger) 12 | { 13 | _logger = logger; 14 | this.httpClient = httpClient; 15 | } 16 | public async Task> GetProducts() 17 | { 18 | List? products = null; 19 | try 20 | { 21 | var response = await httpClient.GetAsync("/api/Product"); 22 | var responseText = await response.Content.ReadAsStringAsync(); 23 | 24 | _logger.LogInformation($"Http status code: {response.StatusCode}"); 25 | _logger.LogInformation($"Http response content: {responseText}"); 26 | 27 | if (response.IsSuccessStatusCode) 28 | { 29 | var options = new JsonSerializerOptions 30 | { 31 | PropertyNameCaseInsensitive = true 32 | }; 33 | 34 | products = await response.Content.ReadFromJsonAsync(ProductSerializerContext.Default.ListProduct); 35 | } 36 | } 37 | catch (Exception ex) 38 | { 39 | _logger.LogError(ex, "Error during GetProducts."); 40 | } 41 | 42 | return products ?? new List(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/Store.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | preview 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "ProductEndpoint": "http://localhost:32001", 11 | "ProductEndpointHttps": "https://localhost:32001" 12 | } 13 | -------------------------------------------------------------------------------- /dotnet-kubernetes/Store/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-kubernetes/Store/wwwroot/favicon.png -------------------------------------------------------------------------------- /dotnet-kubernetes/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | 5 | frontend: 6 | image: store:latest 7 | environment: 8 | - ProductEndpoint=http://backend:8080 9 | ports: 10 | - "32000:8080" 11 | depends_on: 12 | - backend 13 | backend: 14 | image: products:latest 15 | ports: 16 | - "32001:8080" -------------------------------------------------------------------------------- /dotnet-kubernetes/eShopLite.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34004.107 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataEntities", "DataEntities\DataEntities.csproj", "{E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Products", "Products\Products.csproj", "{3366FB0E-CCF3-4620-924E-F2DA34BC00F8}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Store", "Store\Store.csproj", "{2E156904-6754-43F5-8B27-9B9D6479D9FC}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {F9C7AE25-263B-4A02-9BC0-632370BB1004} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /dotnet-kubernetes/finished-files/backend-deploy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: productsbackend 6 | spec: 7 | replicas: 1 8 | template: 9 | metadata: 10 | labels: 11 | app: productsbackend 12 | spec: 13 | containers: 14 | - name: productsbackend 15 | image: [YOUR DOCKER USER NAME]/productservice:latest 16 | ports: 17 | - containerPort: 80 18 | env: 19 | - name: ASPNETCORE_URLS 20 | value: http://*:80 21 | selector: 22 | matchLabels: 23 | app: productsbackend 24 | --- 25 | apiVersion: v1 26 | kind: Service 27 | metadata: 28 | name: productsbackend 29 | spec: 30 | type: NodePort 31 | ports: 32 | - port: 80 33 | targetPort: 80 34 | nodePort: 32001 35 | selector: 36 | app: productsbackend 37 | -------------------------------------------------------------------------------- /dotnet-kubernetes/finished-files/frontend-deploy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: storefrontend 6 | spec: 7 | replicas: 1 8 | template: 9 | metadata: 10 | labels: 11 | app: storefrontend 12 | spec: 13 | containers: 14 | - name: storefrontend 15 | image: [YOUR DOCKER USER NAME]/storeimage:latest 16 | ports: 17 | - containerPort: 80 18 | env: 19 | - name: ASPNETCORE_URLS 20 | value: http://*:80 21 | - name: ProductEndpoint 22 | value: http://productsbackend 23 | selector: 24 | matchLabels: 25 | app: storefrontend 26 | --- 27 | apiVersion: v1 28 | kind: Service 29 | metadata: 30 | name: storefrontend 31 | spec: 32 | type: NodePort 33 | ports: 34 | - port: 80 35 | targetPort: 80 36 | nodePort: 32000 37 | selector: 38 | app: storefrontend 39 | -------------------------------------------------------------------------------- /dotnet-kubernetes/k3d.yml: -------------------------------------------------------------------------------- 1 | apiVersion: k3d.io/v1alpha2 2 | kind: Simple 3 | servers: 1 4 | network: k3d 5 | kubeAPI: 6 | hostIP: "0.0.0.0" 7 | hostPort: "6443" 8 | ports: 9 | - port: 32000:32000 10 | nodeFilters: 11 | - server[0] 12 | - port: 32001:32001 13 | nodeFilters: 14 | - server[0] 15 | options: 16 | k3d: 17 | wait: true 18 | timeout: "60s" 19 | kubeconfig: 20 | updateDefaultKubeconfig: true 21 | switchCurrentContext: true -------------------------------------------------------------------------------- /dotnet-observability/.dockerignore: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /dotnet-observability/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /dotnet-observability/README.md: -------------------------------------------------------------------------------- 1 | # eShopLite -------------------------------------------------------------------------------- /dotnet-observability/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | 5 | frontend: 6 | image: store:latest 7 | environment: 8 | - ProductEndpoint=http://backend:8080 9 | ports: 10 | - "32000:8080" 11 | depends_on: 12 | - backend 13 | backend: 14 | image: products:latest 15 | ports: 16 | - "32001:8080" -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/DataEntities/DataEntities.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/DataEntities/Product.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace DataEntities; 4 | 5 | public class Product 6 | { 7 | [JsonPropertyName("id")] 8 | public int Id { get; set; } 9 | 10 | [JsonPropertyName("name")] 11 | public string? Name { get; set; } 12 | 13 | [JsonPropertyName("description")] 14 | public string? Description { get; set; } 15 | 16 | [JsonPropertyName("price")] 17 | public decimal Price { get; set; } 18 | 19 | [JsonPropertyName("imageUrl")] 20 | public string? ImageUrl { get; set; } 21 | 22 | [JsonPropertyName("stock")] 23 | public int Stock { get; set; } 24 | } 25 | 26 | 27 | [JsonSerializable(typeof(List))] 28 | public sealed partial class ProductSerializerContext : JsonSerializerContext 29 | { 30 | } -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "dotnet-ef": { 6 | "version": "7.0.10", 7 | "commands": [ 8 | "dotnet-ef" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/Database.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/eShopLite/Products/Database.db -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/Database.db-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/eShopLite/Products/Database.db-shm -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/Database.db-wal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/eShopLite/Products/Database.db-wal -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build 2 | 3 | WORKDIR /DataEntities 4 | COPY "eShopLite/DataEntities/DataEntities.csproj" . 5 | RUN dotnet restore 6 | COPY "eShopLite/DataEntities" . 7 | RUN dotnet publish -c release -o /app 8 | 9 | WORKDIR /src 10 | COPY "eShopLite/Products/Products.csproj" . 11 | RUN dotnet restore 12 | COPY "eShopLite/Products" . 13 | RUN dotnet publish -c release -o /app 14 | 15 | FROM mcr.microsoft.com/dotnet/aspnet:8.0 16 | WORKDIR /app 17 | EXPOSE 80 18 | EXPOSE 443 19 | COPY --from=build /app . 20 | ENTRYPOINT ["dotnet", "Products.dll"] -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/Products.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | all 21 | runtime; build; native; contentfiles; analyzers; buildtransitive 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/Products.http: -------------------------------------------------------------------------------- 1 | @HostAddress = http://localhost:5228 2 | 3 | GET {{HostAddress}}/api/Product 4 | Accept: application/json 5 | 6 | ### 7 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Products.Data; 3 | using Products.Endpoints; 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | builder.Services.AddDbContext(options => 7 | options.UseSqlite(builder.Configuration.GetConnectionString("ProductsContext") ?? throw new InvalidOperationException("Connection string 'ProductsContext' not found."))); 8 | 9 | // Add observability code here 10 | 11 | // Add services to the container. 12 | var app = builder.Build(); 13 | 14 | // Configure the HTTP request pipeline. 15 | app.MapProductEndpoints(); 16 | 17 | app.UseStaticFiles(); 18 | 19 | app.CreateDbIfNotExists(); 20 | 21 | app.Run(); 22 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:49179", 8 | "sslPort": 44375 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "launchUrl": "api/Product", 17 | "applicationUrl": "http://localhost:5228", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "https": { 23 | "commandName": "Project", 24 | "dotnetRunMessages": true, 25 | "launchBrowser": true, 26 | "launchUrl": "api/Product", 27 | "applicationUrl": "https://localhost:7130;http://localhost:5228", 28 | "environmentVariables": { 29 | "ASPNETCORE_ENVIRONMENT": "Development" 30 | } 31 | }, 32 | "IIS Express": { 33 | "commandName": "IISExpress", 34 | "launchBrowser": true, 35 | "launchUrl": "api/Product", 36 | "environmentVariables": { 37 | "ASPNETCORE_ENVIRONMENT": "Development" 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "ProductsContext": "Data Source=/home/app/Database.db" 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/wwwroot/images/product1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/eShopLite/Products/wwwroot/images/product1.png -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/wwwroot/images/product2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/eShopLite/Products/wwwroot/images/product2.png -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/wwwroot/images/product3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/eShopLite/Products/wwwroot/images/product3.png -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/wwwroot/images/product4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/eShopLite/Products/wwwroot/images/product4.png -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/wwwroot/images/product5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/eShopLite/Products/wwwroot/images/product5.png -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/wwwroot/images/product6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/eShopLite/Products/wwwroot/images/product6.png -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/wwwroot/images/product7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/eShopLite/Products/wwwroot/images/product7.png -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/wwwroot/images/product8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/eShopLite/Products/wwwroot/images/product8.png -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Products/wwwroot/images/product9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/eShopLite/Products/wwwroot/images/product9.png -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/Components/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | 19 |
20 | An unhandled error has occurred. 21 | Reload 22 | 🗙 23 |
24 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/Components/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 24 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/Components/ModalDialog.razor: -------------------------------------------------------------------------------- 1 | 24 | 25 | @code { 26 | private int QuantityEntered { get; set; } 27 | [Parameter] public string Title { get; set; } 28 | [Parameter] public string Text { get; set; } 29 | [Parameter] public EventCallback OnClose { get; set; } 30 | private Task ModalCancel() 31 | { 32 | return OnClose.InvokeAsync(new ModalDialogResponse() 33 | { 34 | Confirm = false, 35 | Quantity = 0 36 | }); 37 | } 38 | 39 | private Task ModalOk() 40 | { 41 | return OnClose.InvokeAsync(new ModalDialogResponse() 42 | { 43 | Confirm = true, 44 | Quantity = QuantityEntered 45 | }); 46 | } 47 | } -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/Components/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Home 4 | 5 |

Home

6 | 7 | Welcome to the best e-commerce stocker management platform in the world - eShopLite! 8 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/Components/Routes.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using static Microsoft.AspNetCore.Components.Web.RenderMode 8 | @using Microsoft.JSInterop 9 | @using Store 10 | @using Store.Components -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build 2 | 3 | WORKDIR /DataEntities 4 | COPY "eShopLite/DataEntities/DataEntities.csproj" . 5 | RUN dotnet restore 6 | COPY "eShopLite/DataEntities" . 7 | RUN dotnet publish -c release -o /app 8 | 9 | WORKDIR /src 10 | COPY "eShopLite/Store/Store.csproj" . 11 | RUN dotnet restore 12 | COPY "eShopLite/Store" . 13 | RUN dotnet publish -c release -o /app 14 | 15 | FROM mcr.microsoft.com/dotnet/aspnet:8.0 16 | WORKDIR /app 17 | EXPOSE 80 18 | EXPOSE 443 19 | COPY --from=build /app . 20 | ENTRYPOINT ["dotnet", "Store.dll"] -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/Program.cs: -------------------------------------------------------------------------------- 1 | using Store.Components; 2 | using Store.Services; 3 | 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | builder.Services.AddSingleton(); 7 | builder.Services.AddHttpClient(c => 8 | { 9 | var url = builder.Configuration["ProductEndpoint"] ?? throw new InvalidOperationException("ProductEndpoint is not set"); 10 | 11 | c.BaseAddress = new(url); 12 | }); 13 | 14 | // Add services to the container. 15 | builder.Services.AddRazorComponents() 16 | .AddInteractiveServerComponents(); 17 | 18 | // Add observability code here 19 | 20 | 21 | var app = builder.Build(); 22 | 23 | // Configure the HTTP request pipeline. 24 | if (!app.Environment.IsDevelopment()) 25 | { 26 | app.UseExceptionHandler("/Error", createScopeForErrors: true); 27 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 28 | app.UseHsts(); 29 | } 30 | 31 | app.UseHttpsRedirection(); 32 | 33 | app.UseStaticFiles(); 34 | app.UseAntiforgery(); 35 | 36 | app.MapRazorComponents() 37 | .AddInteractiveServerRenderMode(); 38 | 39 | app.Run(); 40 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:38240", 8 | "sslPort": 44332 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "applicationUrl": "http://localhost:5158", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "https": { 22 | "commandName": "Project", 23 | "dotnetRunMessages": true, 24 | "launchBrowser": true, 25 | "applicationUrl": "https://localhost:7085;http://localhost:5158", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | }, 30 | "IIS Express": { 31 | "commandName": "IISExpress", 32 | "launchBrowser": true, 33 | "environmentVariables": { 34 | "ASPNETCORE_ENVIRONMENT": "Development" 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/Services/ModalDialogResponse.cs: -------------------------------------------------------------------------------- 1 | namespace Store; 2 | 3 | public class ModalDialogResponse 4 | { 5 | public bool Confirm {get; set;} 6 | public int Quantity {get; set;} 7 | } -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/Services/ProductService.cs: -------------------------------------------------------------------------------- 1 | using DataEntities; 2 | using System.Text.Json; 3 | using System.Text; 4 | 5 | namespace Store.Services; 6 | 7 | public class ProductService 8 | { 9 | HttpClient httpClient; 10 | private readonly ILogger _logger; 11 | 12 | public ProductService(HttpClient httpClient, ILogger logger) 13 | { 14 | _logger = logger; 15 | this.httpClient = httpClient; 16 | } 17 | public async Task> GetProducts() 18 | { 19 | List? products = null; 20 | try 21 | { 22 | var response = await httpClient.GetAsync("/api/Product"); 23 | var responseText = await response.Content.ReadAsStringAsync(); 24 | 25 | _logger.LogInformation($"Http status code: {response.StatusCode}"); 26 | _logger.LogInformation($"Http response content: {responseText}"); 27 | 28 | if (response.IsSuccessStatusCode) 29 | { 30 | var options = new JsonSerializerOptions 31 | { 32 | PropertyNameCaseInsensitive = true 33 | }; 34 | 35 | products = await response.Content.ReadFromJsonAsync(ProductSerializerContext.Default.ListProduct); 36 | } 37 | } 38 | catch (Exception ex) 39 | { 40 | _logger.LogError(ex, "Error during GetProducts."); 41 | } 42 | 43 | return products ?? new List(); 44 | } 45 | 46 | public async Task UpdateStock(int productId, int stockAmount) 47 | { 48 | try 49 | { 50 | var response = await httpClient.PutAsync($"/api/Stock/{productId}?stockAmount={stockAmount}", null); 51 | 52 | if (response.IsSuccessStatusCode) 53 | { 54 | var responseContent = await response.Content.ReadAsStringAsync(); 55 | return true; 56 | } 57 | 58 | return false; 59 | } 60 | catch (Exception ex) 61 | { 62 | // handle error 63 | return false; 64 | } 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/Store.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | preview 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "ProductEndpoint": "http://localhost:32001", 11 | "ProductEndpointHttps": "https://localhost:32001" 12 | } 13 | -------------------------------------------------------------------------------- /dotnet-observability/eShopLite/Store/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/eShopLite/Store/wwwroot/favicon.png -------------------------------------------------------------------------------- /dotnet-observability/finished-files/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | 5 | frontend: 6 | image: storeimage 7 | build: 8 | context: . 9 | dockerfile: ./eShopLite/Store/Dockerfile 10 | environment: 11 | - ProductEndpoint=http://backend:8080 12 | - ImagePrefix=http://localhost:32001/images 13 | - ZIPKIN_URL=http://zipkin:9411 14 | - APPLICATIONINSIGHTS_CONNECTION_STRING=[ADD Your Azure Application Insights Connection String here] 15 | ports: 16 | - "32000:8080" 17 | depends_on: 18 | - backend 19 | - prometheus 20 | - zipkin 21 | 22 | backend: 23 | image: productservice 24 | build: 25 | context: . 26 | dockerfile: ./eShopLite/Products/Dockerfile 27 | environment: 28 | - ZIPKIN_URL=http://zipkin:9411 29 | - APPLICATIONINSIGHTS_CONNECTION_STRING=[ADD Your Azure Application Insights Connection String here] 30 | ports: 31 | - "32001:8080" 32 | depends_on: 33 | - prometheus 34 | 35 | zipkin: 36 | image: openzipkin/zipkin 37 | ports: 38 | - 9411:9411 39 | 40 | prometheus: 41 | image: prom/prometheus 42 | container_name: prometheus 43 | command: 44 | - '--config.file=/etc/prometheus/prometheus.yml' 45 | ports: 46 | - 9090:9090 47 | restart: unless-stopped 48 | volumes: 49 | - ./prometheus:/etc/prometheus 50 | 51 | grafana: 52 | image: grafana/grafana 53 | container_name: grafana 54 | ports: 55 | - 3000:3000 56 | restart: unless-stopped 57 | environment: 58 | - GF_SECURITY_ADMIN_USER=admin 59 | - GF_SECURITY_ADMIN_PASSWORD=grafana 60 | volumes: 61 | - ./grafana/datasource:/etc/grafana/provisioning/datasources 62 | 63 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/DataEntities/DataEntities.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/DataEntities/Product.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace DataEntities; 4 | 5 | public class Product 6 | { 7 | [JsonPropertyName("id")] 8 | public int Id { get; set; } 9 | 10 | [JsonPropertyName("name")] 11 | public string? Name { get; set; } 12 | 13 | [JsonPropertyName("description")] 14 | public string? Description { get; set; } 15 | 16 | [JsonPropertyName("price")] 17 | public decimal Price { get; set; } 18 | 19 | [JsonPropertyName("imageUrl")] 20 | public string? ImageUrl { get; set; } 21 | 22 | [JsonPropertyName("stock")] 23 | public int Stock { get; set; } 24 | } 25 | 26 | 27 | [JsonSerializable(typeof(List))] 28 | public sealed partial class ProductSerializerContext : JsonSerializerContext 29 | { 30 | } -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Diagnostics/Diagnostics.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | Library 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Diagnostics/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Diagnostics": { 4 | "commandName": "Project", 5 | "launchBrowser": true, 6 | "environmentVariables": { 7 | "ASPNETCORE_ENVIRONMENT": "Development" 8 | }, 9 | "applicationUrl": "https://localhost:49391;http://localhost:49392" 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "dotnet-ef": { 6 | "version": "7.0.10", 7 | "commands": [ 8 | "dotnet-ef" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/Database.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/finished-files/eShopLite/Products/Database.db -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/Database.db-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/finished-files/eShopLite/Products/Database.db-shm -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/Database.db-wal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/finished-files/eShopLite/Products/Database.db-wal -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build 2 | 3 | WORKDIR /DataEntities 4 | COPY "eShopLite/DataEntities/DataEntities.csproj" . 5 | RUN dotnet restore 6 | COPY "eShopLite/DataEntities" . 7 | RUN dotnet publish -c release -o /app 8 | 9 | WORKDIR /Diagnostics 10 | COPY "eShopLite/Diagnostics/Diagnostics.csproj" . 11 | RUN dotnet restore 12 | COPY "eShopLite/Diagnostics" . 13 | RUN dotnet publish -c release -o /app 14 | 15 | WORKDIR /src 16 | COPY "eShopLite/Products/Products.csproj" . 17 | RUN dotnet restore 18 | COPY "eShopLite/Products" . 19 | RUN dotnet publish -c release -o /app 20 | 21 | FROM mcr.microsoft.com/dotnet/aspnet:8.0 22 | WORKDIR /app 23 | EXPOSE 80 24 | EXPOSE 443 25 | COPY --from=build /app . 26 | ENTRYPOINT ["dotnet", "Products.dll"] -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/Instrumentation.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using OpenTelemetry.Trace; 3 | 4 | namespace Products.Instrumentation; 5 | 6 | public class Instrumentation 7 | { 8 | public static readonly string ActivitySourceName = "eShopLite.Products"; 9 | 10 | public ActivitySource ActivitySource { get; } = new ActivitySource(ActivitySourceName); 11 | } 12 | 13 | public static class InstrumentationExtensions 14 | { 15 | public static TracerProviderBuilder AddWorkerInstrumentation(this TracerProviderBuilder tracerProviderBuilder) 16 | { 17 | return tracerProviderBuilder.AddSource(Instrumentation.ActivitySourceName); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/Products.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | all 21 | runtime; build; native; contentfiles; analyzers; buildtransitive 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/Products.http: -------------------------------------------------------------------------------- 1 | @HostAddress = http://localhost:5228 2 | 3 | GET {{HostAddress}}/api/Product 4 | Accept: application/json 5 | 6 | ### 7 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/ProductsMetrics.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.Metrics; 3 | 4 | namespace Products.Instrumentation; 5 | 6 | public class ProductsMetrics 7 | { 8 | private readonly Counter _serviceCalls; 9 | private readonly Counter _stockChange; 10 | 11 | public ProductsMetrics(IMeterFactory meterFactory) 12 | { 13 | var meter = meterFactory.Create("eShopLite.Products"); 14 | _serviceCalls = meter.CreateCounter(name: "eshoplite.products.service_calls", unit: "{calls}", description: "Number of times the product service is being called to list all products."); 15 | _stockChange = meter.CreateCounter("eshoplite.products.stock_change", unit: "{stock}", description: "Amount of stock being changed through the product service."); 16 | } 17 | 18 | public void ServiceCalls(int quantity) 19 | { 20 | _serviceCalls.Add(quantity); 21 | } 22 | 23 | public void StockChange(int quantity) 24 | { 25 | _stockChange.Add(quantity); 26 | } 27 | } -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Products.Data; 3 | using Products.Endpoints; 4 | using Products.Instrumentation; 5 | 6 | var builder = WebApplication.CreateBuilder(args); 7 | builder.Services.AddDbContext(options => 8 | options.UseSqlite(builder.Configuration.GetConnectionString("ProductsContext") ?? throw new InvalidOperationException("Connection string 'ProductsContext' not found."))); 9 | 10 | builder.Services.AddObservability("Products", builder.Configuration, ["eShopLite.Products"]); 11 | 12 | // Register the metrics service. 13 | builder.Services.AddSingleton(); 14 | 15 | // Add services to the container. 16 | var app = builder.Build(); 17 | 18 | // Configure the HTTP request pipeline. 19 | app.MapProductEndpoints(); 20 | 21 | app.UseStaticFiles(); 22 | 23 | app.CreateDbIfNotExists(); 24 | 25 | app.MapObservability(); 26 | 27 | app.Run(); 28 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:49179", 8 | "sslPort": 44375 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "launchUrl": "api/Product", 17 | "applicationUrl": "http://localhost:5228", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "https": { 23 | "commandName": "Project", 24 | "dotnetRunMessages": true, 25 | "launchBrowser": true, 26 | "launchUrl": "api/Product", 27 | "applicationUrl": "https://localhost:7130;http://localhost:5228", 28 | "environmentVariables": { 29 | "ASPNETCORE_ENVIRONMENT": "Development" 30 | } 31 | }, 32 | "IIS Express": { 33 | "commandName": "IISExpress", 34 | "launchBrowser": true, 35 | "launchUrl": "api/Product", 36 | "environmentVariables": { 37 | "ASPNETCORE_ENVIRONMENT": "Development" 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "ProductsContext": "Data Source=/home/app/Database.db" 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product1.png -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product2.png -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product3.png -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product4.png -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product5.png -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product6.png -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product7.png -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product8.png -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/finished-files/eShopLite/Products/wwwroot/images/product9.png -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/Components/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | 19 |
20 | An unhandled error has occurred. 21 | Reload 22 | 🗙 23 |
24 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/Components/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 24 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/Components/ModalDialog.razor: -------------------------------------------------------------------------------- 1 | 24 | 25 | @code { 26 | [Parameter] public int QuantityEntered { get; set; } 27 | [Parameter] public string? Title { get; set; } 28 | [Parameter] public string? Text { get; set; } 29 | [Parameter] public EventCallback OnClose { get; set; } 30 | private Task ModalCancel() 31 | { 32 | return OnClose.InvokeAsync(new ModalDialogResponse() 33 | { 34 | Confirm = false, 35 | Quantity = 0 36 | }); 37 | } 38 | 39 | private Task ModalOk() 40 | { 41 | return OnClose.InvokeAsync(new ModalDialogResponse() 42 | { 43 | Confirm = true, 44 | Quantity = QuantityEntered 45 | }); 46 | } 47 | } -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/Components/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Home 4 | 5 |

Home

6 | 7 | Welcome to the best e-commerce stocker management platform in the world - eShopLite! 8 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/Components/Routes.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using static Microsoft.AspNetCore.Components.Web.RenderMode 8 | @using Microsoft.JSInterop 9 | @using Store 10 | @using Store.Components -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build 2 | 3 | WORKDIR /DataEntities 4 | COPY "eShopLite/DataEntities/DataEntities.csproj" . 5 | RUN dotnet restore 6 | COPY "eShopLite/DataEntities" . 7 | RUN dotnet publish -c release -o /app 8 | 9 | WORKDIR /Diagnostics 10 | COPY "eShopLite/Diagnostics/Diagnostics.csproj" . 11 | RUN dotnet restore 12 | COPY "eShopLite/Diagnostics" . 13 | RUN dotnet publish -c release -o /app 14 | 15 | WORKDIR /src 16 | COPY "eShopLite/Store/Store.csproj" . 17 | RUN dotnet restore 18 | COPY "eShopLite/Store" . 19 | RUN dotnet publish -c release -o /app 20 | 21 | FROM mcr.microsoft.com/dotnet/aspnet:8.0 22 | WORKDIR /app 23 | EXPOSE 80 24 | EXPOSE 443 25 | COPY --from=build /app . 26 | ENTRYPOINT ["dotnet", "Store.dll"] -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/Program.cs: -------------------------------------------------------------------------------- 1 | using Store.Components; 2 | using Store.Services; 3 | 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | builder.Services.AddObservability("Store", builder.Configuration); 7 | 8 | builder.Services.AddSingleton(); 9 | builder.Services.AddHttpClient(c => 10 | { 11 | var url = builder.Configuration["ProductEndpoint"] ?? throw new InvalidOperationException("ProductEndpoint is not set"); 12 | 13 | c.BaseAddress = new(url); 14 | }); 15 | 16 | // Add services to the container. 17 | builder.Services.AddRazorComponents() 18 | .AddInteractiveServerComponents(); 19 | 20 | // Add logging 21 | 22 | 23 | var app = builder.Build(); 24 | 25 | // Configure the HTTP request pipeline. 26 | if (!app.Environment.IsDevelopment()) 27 | { 28 | app.UseExceptionHandler("/Error", createScopeForErrors: true); 29 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 30 | app.UseHsts(); 31 | } 32 | 33 | app.UseHttpsRedirection(); 34 | 35 | app.UseStaticFiles(); 36 | app.UseAntiforgery(); 37 | 38 | app.MapRazorComponents() 39 | .AddInteractiveServerRenderMode(); 40 | 41 | app.MapObservability(); 42 | 43 | app.Run(); 44 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:38240", 8 | "sslPort": 44332 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "applicationUrl": "http://localhost:5158", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "https": { 22 | "commandName": "Project", 23 | "dotnetRunMessages": true, 24 | "launchBrowser": true, 25 | "applicationUrl": "https://localhost:7085;http://localhost:5158", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | }, 30 | "IIS Express": { 31 | "commandName": "IISExpress", 32 | "launchBrowser": true, 33 | "environmentVariables": { 34 | "ASPNETCORE_ENVIRONMENT": "Development" 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/Services/ModalDialogResponse.cs: -------------------------------------------------------------------------------- 1 | namespace Store; 2 | 3 | public class ModalDialogResponse 4 | { 5 | public bool Confirm {get; set;} 6 | public int Quantity {get; set;} 7 | } -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/Services/ProductService.cs: -------------------------------------------------------------------------------- 1 | using DataEntities; 2 | using System.Text.Json; 3 | using System.Text; 4 | 5 | namespace Store.Services; 6 | 7 | public class ProductService 8 | { 9 | HttpClient httpClient; 10 | private readonly ILogger _logger; 11 | 12 | public ProductService(HttpClient httpClient, ILogger logger) 13 | { 14 | _logger = logger; 15 | this.httpClient = httpClient; 16 | } 17 | public async Task> GetProducts() 18 | { 19 | List? products = null; 20 | try 21 | { 22 | var response = await httpClient.GetAsync("/api/Product"); 23 | var responseText = await response.Content.ReadAsStringAsync(); 24 | 25 | _logger.LogInformation($"Http status code: {response.StatusCode}"); 26 | _logger.LogInformation($"Http response content: {responseText}"); 27 | 28 | if (response.IsSuccessStatusCode) 29 | { 30 | var options = new JsonSerializerOptions 31 | { 32 | PropertyNameCaseInsensitive = true 33 | }; 34 | 35 | products = await response.Content.ReadFromJsonAsync(ProductSerializerContext.Default.ListProduct); 36 | } 37 | } 38 | catch (Exception ex) 39 | { 40 | _logger.LogError(ex, "Error during GetProducts."); 41 | } 42 | 43 | return products ?? new List(); 44 | } 45 | 46 | public async Task UpdateStock(int productId, int stockAmount) 47 | { 48 | try 49 | { 50 | var response = await httpClient.PutAsync($"/api/Stock/{productId}?stockAmount={stockAmount}", null); 51 | 52 | if (response.IsSuccessStatusCode) 53 | { 54 | var responseContent = await response.Content.ReadAsStringAsync(); 55 | return true; 56 | } 57 | 58 | return false; 59 | } 60 | catch (Exception ex) 61 | { 62 | // handle error 63 | return false; 64 | } 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/Store.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | preview 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "ProductEndpoint": "http://localhost:5228", 11 | "ProductEndpointHttps": "https://localhost:5228/", 12 | "ImagePrefix": "http://localhost:5228/images" 13 | } 14 | -------------------------------------------------------------------------------- /dotnet-observability/finished-files/eShopLite/Store/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-observability/finished-files/eShopLite/Store/wwwroot/favicon.png -------------------------------------------------------------------------------- /dotnet-observability/finished-files/grafana/datasource/datasource.yml: -------------------------------------------------------------------------------- 1 | apiVersion: 1 2 | 3 | datasources: 4 | - name: Prometheus 5 | type: prometheus 6 | url: http://prometheus:9090 7 | isDefault: true 8 | access: proxy 9 | editable: true -------------------------------------------------------------------------------- /dotnet-observability/finished-files/prometheus/prometheus.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 60s 3 | 4 | scrape_configs: 5 | - job_name: 'products' 6 | static_configs: 7 | - targets: ['backend:8080'] 8 | - job_name: 'store' 9 | static_configs: 10 | - targets: ['frontend:8080'] 11 | -------------------------------------------------------------------------------- /dotnet-resiliency/.dockerignore: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /dotnet-resiliency/DataEntities/DataEntities.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /dotnet-resiliency/DataEntities/Product.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace DataEntities; 4 | 5 | public class Product 6 | { 7 | [JsonPropertyName("id")] 8 | public int Id { get; set; } 9 | 10 | [JsonPropertyName("name")] 11 | public string? Name { get; set; } 12 | 13 | [JsonPropertyName("description")] 14 | public string? Description { get; set; } 15 | 16 | [JsonPropertyName("price")] 17 | public decimal Price { get; set; } 18 | 19 | [JsonPropertyName("imageUrl")] 20 | public string? ImageUrl { get; set; } 21 | } 22 | 23 | 24 | [JsonSerializable(typeof(List))] 25 | public sealed partial class ProductSerializerContext : JsonSerializerContext 26 | { 27 | } -------------------------------------------------------------------------------- /dotnet-resiliency/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /dotnet-resiliency/Products/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "dotnet-ef": { 6 | "version": "7.0.10", 7 | "commands": [ 8 | "dotnet-ef" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-resiliency/Products/Products.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | all 21 | runtime; build; native; contentfiles; analyzers; buildtransitive 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /dotnet-resiliency/Products/Products.http: -------------------------------------------------------------------------------- 1 | @HostAddress = http://localhost:5228 2 | 3 | GET {{HostAddress}}/api/Product 4 | Accept: application/json 5 | 6 | ### 7 | -------------------------------------------------------------------------------- /dotnet-resiliency/Products/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using Products.Data; 3 | using Products.Endpoints; 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | builder.Services.AddDbContext(options => 7 | options.UseSqlite(builder.Configuration.GetConnectionString("ProductsContext") ?? throw new InvalidOperationException("Connection string 'ProductsContext' not found."))); 8 | 9 | // Add services to the container. 10 | var app = builder.Build(); 11 | 12 | // Configure the HTTP request pipeline. 13 | app.MapProductEndpoints(); 14 | 15 | app.UseStaticFiles(); 16 | 17 | app.CreateDbIfNotExists(); 18 | 19 | app.Run(); 20 | -------------------------------------------------------------------------------- /dotnet-resiliency/Products/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:49179", 8 | "sslPort": 44375 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "launchUrl": "api/Product", 17 | "applicationUrl": "http://localhost:5228", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "https": { 23 | "commandName": "Project", 24 | "dotnetRunMessages": true, 25 | "launchBrowser": true, 26 | "launchUrl": "api/Product", 27 | "applicationUrl": "https://localhost:7130;http://localhost:5228", 28 | "environmentVariables": { 29 | "ASPNETCORE_ENVIRONMENT": "Development" 30 | } 31 | }, 32 | "IIS Express": { 33 | "commandName": "IISExpress", 34 | "launchBrowser": true, 35 | "launchUrl": "api/Product", 36 | "environmentVariables": { 37 | "ASPNETCORE_ENVIRONMENT": "Development" 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dotnet-resiliency/Products/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-resiliency/Products/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "ProductsContext": "Data Source=/home/app/Database.db" 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-resiliency/Products/wwwroot/images/product1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-resiliency/Products/wwwroot/images/product1.png -------------------------------------------------------------------------------- /dotnet-resiliency/Products/wwwroot/images/product2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-resiliency/Products/wwwroot/images/product2.png -------------------------------------------------------------------------------- /dotnet-resiliency/Products/wwwroot/images/product3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-resiliency/Products/wwwroot/images/product3.png -------------------------------------------------------------------------------- /dotnet-resiliency/Products/wwwroot/images/product4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-resiliency/Products/wwwroot/images/product4.png -------------------------------------------------------------------------------- /dotnet-resiliency/Products/wwwroot/images/product5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-resiliency/Products/wwwroot/images/product5.png -------------------------------------------------------------------------------- /dotnet-resiliency/Products/wwwroot/images/product6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-resiliency/Products/wwwroot/images/product6.png -------------------------------------------------------------------------------- /dotnet-resiliency/Products/wwwroot/images/product7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-resiliency/Products/wwwroot/images/product7.png -------------------------------------------------------------------------------- /dotnet-resiliency/Products/wwwroot/images/product8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-resiliency/Products/wwwroot/images/product8.png -------------------------------------------------------------------------------- /dotnet-resiliency/Products/wwwroot/images/product9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-resiliency/Products/wwwroot/images/product9.png -------------------------------------------------------------------------------- /dotnet-resiliency/Store/Components/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /dotnet-resiliency/Store/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | 19 |
20 | An unhandled error has occurred. 21 | Reload 22 | 🗙 23 |
24 | -------------------------------------------------------------------------------- /dotnet-resiliency/Store/Components/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 24 | -------------------------------------------------------------------------------- /dotnet-resiliency/Store/Components/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Home 4 | 5 |

Home

6 | 7 | Welcome to the best e-commerce platform in the world - eShopLite! 8 | -------------------------------------------------------------------------------- /dotnet-resiliency/Store/Components/Pages/Products.razor: -------------------------------------------------------------------------------- 1 | @page "/products" 2 | @using DataEntities 3 | @using Store.Services 4 | @inject ProductService ProductService 5 | @inject IConfiguration Configuration 6 | @attribute [StreamRendering(true)] 7 | 8 | Products 9 | 10 |

Products

11 | 12 |

Here are some of our amazing outdoor products that you can purchase.

13 | 14 | @if (products == null) 15 | { 16 |

Loading...

17 | } 18 | else if (products.Count == 0) { 19 |

There is a problem loading our products. Please try again later.

20 | } 21 | else 22 | { 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | @foreach (var product in products) 34 | { 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | } 43 | 44 |
ImageNameDescriptionPrice
@product.Name@product.Description@product.Price
45 | } 46 | 47 | @code { 48 | private List? products; 49 | 50 | protected override async Task OnInitializedAsync() 51 | { 52 | // Simulate asynchronous loading to demonstrate streaming rendering 53 | await Task.Delay(500); 54 | products = await ProductService.GetProducts(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /dotnet-resiliency/Store/Components/Routes.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /dotnet-resiliency/Store/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.JSInterop 8 | @using Store 9 | @using Store.Components 10 | -------------------------------------------------------------------------------- /dotnet-resiliency/Store/Program.cs: -------------------------------------------------------------------------------- 1 | using Store.Components; 2 | using Store.Services; 3 | 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | builder.Services.AddSingleton(); 7 | builder.Services.AddHttpClient(c => 8 | { 9 | var url = builder.Configuration["ProductEndpoint"] ?? throw new InvalidOperationException("ProductEndpoint is not set"); 10 | 11 | c.BaseAddress = new(url); 12 | }); 13 | 14 | // Add services to the container. 15 | builder.Services.AddRazorComponents() 16 | .AddInteractiveServerComponents(); 17 | 18 | var app = builder.Build(); 19 | 20 | // Configure the HTTP request pipeline. 21 | if (!app.Environment.IsDevelopment()) 22 | { 23 | app.UseExceptionHandler("/Error", createScopeForErrors: true); 24 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 25 | app.UseHsts(); 26 | } 27 | 28 | app.UseHttpsRedirection(); 29 | 30 | app.UseStaticFiles(); 31 | app.UseAntiforgery(); 32 | 33 | app.MapRazorComponents() 34 | .AddInteractiveServerRenderMode(); 35 | 36 | app.Run(); 37 | -------------------------------------------------------------------------------- /dotnet-resiliency/Store/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:38240", 8 | "sslPort": 44332 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "applicationUrl": "http://localhost:5158", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "https": { 22 | "commandName": "Project", 23 | "dotnetRunMessages": true, 24 | "launchBrowser": true, 25 | "applicationUrl": "https://localhost:7085;http://localhost:5158", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | }, 30 | "IIS Express": { 31 | "commandName": "IISExpress", 32 | "launchBrowser": true, 33 | "environmentVariables": { 34 | "ASPNETCORE_ENVIRONMENT": "Development" 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /dotnet-resiliency/Store/Services/ProductService.cs: -------------------------------------------------------------------------------- 1 | using DataEntities; 2 | using System.Text.Json; 3 | 4 | namespace Store.Services; 5 | 6 | public class ProductService 7 | { 8 | HttpClient httpClient; 9 | private readonly ILogger _logger; 10 | 11 | public ProductService(HttpClient httpClient, ILogger logger) 12 | { 13 | _logger = logger; 14 | this.httpClient = httpClient; 15 | } 16 | public async Task> GetProducts() 17 | { 18 | List? products = null; 19 | try 20 | { 21 | var response = await httpClient.GetAsync("/api/Product"); 22 | var responseText = await response.Content.ReadAsStringAsync(); 23 | 24 | _logger.LogInformation($"Http status code: {response.StatusCode}"); 25 | _logger.LogInformation($"Http response content: {responseText}"); 26 | 27 | if (response.IsSuccessStatusCode) 28 | { 29 | var options = new JsonSerializerOptions 30 | { 31 | PropertyNameCaseInsensitive = true 32 | }; 33 | 34 | products = await response.Content.ReadFromJsonAsync(ProductSerializerContext.Default.ListProduct); 35 | } 36 | } 37 | catch (Exception ex) 38 | { 39 | _logger.LogError(ex, "Error during GetProducts."); 40 | } 41 | 42 | return products ?? new List(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /dotnet-resiliency/Store/Store.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | preview 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /dotnet-resiliency/Store/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-resiliency/Store/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "ProductEndpoint": "http://localhost:32001", 11 | "ProductEndpointHttps": "https://localhost:32001" 12 | } 13 | -------------------------------------------------------------------------------- /dotnet-resiliency/Store/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicrosoftDocs/mslearn-dotnet-cloudnative/1f26ad13d037daf0dbdaf058ee79dba779627182/dotnet-resiliency/Store/wwwroot/favicon.png -------------------------------------------------------------------------------- /dotnet-resiliency/backend-deploy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: productsbackend 6 | spec: 7 | replicas: 1 8 | template: 9 | metadata: 10 | labels: 11 | app: productsbackend 12 | spec: 13 | containers: 14 | - name: productsbackend 15 | image: [YOUR DOCKER USER NAME]/productservice:latest 16 | ports: 17 | - containerPort: 80 18 | env: 19 | - name: ASPNETCORE_URLS 20 | value: http://*:80 21 | selector: 22 | matchLabels: 23 | app: productsbackend 24 | --- 25 | apiVersion: v1 26 | kind: Service 27 | metadata: 28 | name: productsbackend 29 | spec: 30 | type: NodePort 31 | ports: 32 | - port: 80 33 | targetPort: 80 34 | nodePort: 32001 35 | selector: 36 | app: productsbackend 37 | -------------------------------------------------------------------------------- /dotnet-resiliency/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | 5 | frontend: 6 | image: store:latest 7 | environment: 8 | - ProductEndpoint=http://backend:8080 9 | ports: 10 | - "32000:8080" 11 | depends_on: 12 | - backend 13 | backend: 14 | image: products:latest 15 | ports: 16 | - "32001:8080" -------------------------------------------------------------------------------- /dotnet-resiliency/eShopLite.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34004.107 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataEntities", "DataEntities\DataEntities.csproj", "{E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Products", "Products\Products.csproj", "{3366FB0E-CCF3-4620-924E-F2DA34BC00F8}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Store", "Store\Store.csproj", "{2E156904-6754-43F5-8B27-9B9D6479D9FC}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {E42C986A-98CA-4FBC-9F9F-88F8C7CB1603}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {3366FB0E-CCF3-4620-924E-F2DA34BC00F8}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {2E156904-6754-43F5-8B27-9B9D6479D9FC}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {F9C7AE25-263B-4A02-9BC0-632370BB1004} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /dotnet-resiliency/finished-files/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Http.Resilience; 2 | using Store.Components; 3 | using Store.Services; 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | 7 | builder.Services.AddSingleton(); 8 | builder.Services.AddHttpClient(c => 9 | { 10 | var url = builder.Configuration["ProductEndpoint"] ?? throw new InvalidOperationException("ProductEndpoint is not set"); 11 | 12 | c.BaseAddress = new(url); 13 | }).AddStandardResilienceHandler( options => 14 | { 15 | options.RetryOptions.RetryCount = 7; 16 | options.TotalRequestTimeoutOptions.Timeout = TimeSpan.FromSeconds(260); 17 | }); 18 | 19 | // Add services to the container. 20 | builder.Services.AddRazorComponents() 21 | .AddServerComponents(); 22 | 23 | var app = builder.Build(); 24 | 25 | // Configure the HTTP request pipeline. 26 | if (!app.Environment.IsDevelopment()) 27 | { 28 | app.UseExceptionHandler("/Error"); 29 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 30 | app.UseHsts(); 31 | } 32 | 33 | app.UseHttpsRedirection(); 34 | 35 | app.UseStaticFiles(); 36 | 37 | app.MapRazorComponents() 38 | .AddServerRenderMode(); 39 | 40 | app.Run(); 41 | -------------------------------------------------------------------------------- /dotnet-resiliency/frontend-deploy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: storefrontend 6 | spec: 7 | replicas: 1 8 | template: 9 | metadata: 10 | labels: 11 | app: storefrontend 12 | spec: 13 | containers: 14 | - name: storefrontend 15 | image: [YOUR DOCKER USER NAME]/storeimage:latest 16 | ports: 17 | - containerPort: 80 18 | env: 19 | - name: ASPNETCORE_URLS 20 | value: http://*:80 21 | - name: ProductEndpoint 22 | value: http://productsbackend 23 | selector: 24 | matchLabels: 25 | app: storefrontend 26 | --- 27 | apiVersion: v1 28 | kind: Service 29 | metadata: 30 | name: storefrontend 31 | spec: 32 | type: NodePort 33 | ports: 34 | - port: 80 35 | targetPort: 80 36 | nodePort: 32000 37 | selector: 38 | app: storefrontend 39 | -------------------------------------------------------------------------------- /dotnet-resiliency/k3d.yml: -------------------------------------------------------------------------------- 1 | apiVersion: k3d.io/v1alpha2 2 | kind: Simple 3 | servers: 1 4 | network: k3d 5 | kubeAPI: 6 | hostIP: "0.0.0.0" 7 | hostPort: "6443" 8 | ports: 9 | - port: 32000:32000 10 | nodeFilters: 11 | - server[0] 12 | - port: 32001:32001 13 | nodeFilters: 14 | - server[0] 15 | options: 16 | k3d: 17 | wait: true 18 | timeout: "60s" 19 | kubeconfig: 20 | updateDefaultKubeconfig: true 21 | switchCurrentContext: true --------------------------------------------------------------------------------