dotnet-architecture / News

News on .NET Architecture Guidance, eShopOnContainers and all the reference apps in dotnet-architecture
MIT License
1.1k stars 79 forks source link

Microservices eBook & Samples updated to .NET Core 2.2 #26

Open nishanil opened 5 years ago

nishanil commented 5 years ago

🎉We just published the v2.2 of the Microservices eBook.🎉

The new version covers the built-in health checks feature that was released in ASP .NET Core 2.2 and other updates from .NET Core 2.2.

Download: https://aka.ms/microservicesebook ✔

The Reference Sample https://github.com/dotnet-architecture/eshopOnContainers is also updated.

cover-med

Do check them out and let us know your feedback!

Thank You!

wdhastings commented 5 years ago

Working fine for me on docker compose, but failing on a local kubernetes deployment. The containers for both the webmvc and webspa will not run. I don't think they have to run on docker-compose but kubernetes will not keep the pods alive if the program exits.

Here's the error being thrown in the kubernetes log from webspa:

Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: url at Guard.ArgumentNotNullOrEmpty(String argumentName, String value) in /src/src/BuildingBlocks/HealthChecks/src/common/Guard.cs:line 21 at Microsoft.Extensions.HealthChecks.HealthCheckBuilderExtensions.AddUrlCheck(HealthCheckBuilder builder, String url, Func2 checkFunc, TimeSpan cacheDuration) in /src/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Checks/UrlChecks.cs:line 76 at Microsoft.Extensions.HealthChecks.HealthCheckBuilderExtensions.AddUrlCheck(HealthCheckBuilder builder, String url, TimeSpan cacheDuration) in /src/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Checks/UrlChecks.cs:line 23 at eShopConContainers.WebSPA.Startup.b__6_0(HealthCheckBuilder checks) in /src/src/Web/WebSPA/Startup.cs:line 49 at Microsoft.Extensions.DependencyInjection.HealthCheckServiceCollectionExtensions.AddHealthChecks(IServiceCollection services, Action1 checks) in /src/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/HealthCheckServiceCollectionExtensions.cs:line 27 at eShopConContainers.WebSPA.Startup.ConfigureServices(IServiceCollection services) in /src/src/Web/WebSPA/Startup.cs:line 42 --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services) at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at eShopConContainers.WebSPA.Program.Main(String[] args) in /src/src/Web/WebSPA/Program.cs:line 13

All other pods are running. Webstatus is reachable but is reporting all services as unhealthy.

Update: If you'd like to fix this, the problem is that you have incorrect URL strings in your Startup.cs. You're referencing strings with "HC" at the end, e.g. "PurchaseUrlHC" when those aren't defined in your config file.

nishanil commented 5 years ago

@wdhastings We're looking into this right now. I will keep you posted.

wdhastings commented 5 years ago

@nishanil Thank you. I noticed that the basket service is also not working on kubernetes even though the service is up and reports healthy. It does work on docker-compose. I haven't had a chance to troubleshoot it, but I'll look later if you don't get to it.

nishanil commented 5 years ago

@wdhastings It looks like our CI systems did not push newer images to Docker Hub. Can you check now?

fabricioveronez commented 5 years ago

Where is the ePub version ?

wdhastings commented 5 years ago

@nishanil All seems good now, at least on Edge. Chrome is giving me a security violation trying to load jquery:

Refused to load the script 'http://localhost/identity/lib/jquery/jquery.js' because it violates the following Content Security Policy directive: "script-src 'unsafe-inline'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

wdhastings commented 5 years ago

@nishanil I spoke too soon. I'm still getting a 500 error trying to add to the cart, even on Edge. The error returned is:

HTTP500: SERVER ERROR - The server encountered an unexpected condition that prevented it from fulfilling the request. (XHR)POST - http://localhost/webshoppingapigw/api/v1/basket/

The webstatus service is reporting all services as healthy. I'm sorry I don't have more time to investigate right now.

nishanil commented 5 years ago

@fabricioveronez eReader formats will be available soon.

nishanil commented 5 years ago

@fabricioveronez eReader formats are now available

https://aka.ms/microservicesebookmobi https://aka.ms/microservicesebookepub

neoAnkit commented 4 years ago

@nishanil All seems good now, at least on Edge. Chrome is giving me a security violation trying to load jquery:

Refused to load the script 'http://localhost/identity/lib/jquery/jquery.js' because it violates the following Content Security Policy directive: "script-src 'unsafe-inline'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

did you get a fix on this?

Roland1975 commented 4 years ago

@nishanil replace localhost by docker.for.win.localhost. This value is set in /src/.env

neoAnkit commented 4 years ago

@nishanil replace localhost by docker.for.win.localhost. This value is set in /src/.env

I am using linux container. Will this solution work there too?

right now my .env settings are:- ESHOP_EXTERNAL_DNS_NAME_OR_IP=host.docker.internal ESHOP_STORAGE_CATALOG_URL=http://host.docker.internal:5202/c/api/v1/catalog/items/[0]/pic/ ESHOP_STORAGE_MARKETING_URL=http://host.docker.internal:5110/api/v1/campaigns/[0]/pic/

Roland1975 commented 4 years ago

@nishanil In my .env file, here is an excerpt applying for linux: // Use this values to run the app locally in Linux // ESHOP_EXTERNAL_DNS_NAME_OR_IP=docker.for.linux.localhost

So, docker.for.linux.localhost seems appropriate.

neoAnkit commented 4 years ago

@nishanil In my .env file, here is an excerpt applying for linux: // Use this values to run the app locally in Linux // ESHOP_EXTERNAL_DNS_NAME_OR_IP=docker.for.linux.localhost

So, docker.for.linux.localhost seems appropriate.

I am sorry i should have been more clear. I am running solution on windows machine but using linux container instead of windows. Your inputs pleaase

Roland1975 commented 4 years ago

It was my case,too: running linux container on a window host. In your browser, change http://localhost to http://docker.for.win.localhost. It did the trick for me.

neoAnkit commented 4 years ago

It was my case,too: running linux container on a window host. In your browser, change http://localhost to http://docker.for.win.localhost. It did the trick for me.

so i did changes in .env file as your suggested. Also in identityDB i changed the urls to dowcker.for.win.localhost. Running the solution now. Will keep you posted.

In the meantime, could you please guide me how to ensure that any code changes are reflected quickly in each deployed service? Right now if i even make text changes in website, i have to rerun the entire source code to verify my changes.

neoAnkit commented 4 years ago

If you're using Docker for Windows/Mac host.docker.internal can be used to point to the host machine.

Say you're running an app on a host machine (either outside docker, or within docker but on the host network) at port 8080, you can reach it from within the docker network at host.docker.internal:8080.

If you're trying to reach a container within the network from another container within the same network you can do it directly through service discovery.

I tried the changes. I made the changes in .env and database and open login page(on chrome) from url http://host.docker.internal:5100/ but after clicking submit shows the following error and hence not able to login:-

Refused to load the script 'http://localhost/identity/lib/jquery/jquery.js' because it violates the following Content Security Policy directive: "script-src 'unsafe-inline'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

On Ie the website is not opening