Angular SPA - REST API - sql

I want to build a REST API for use with an Angular SPA.
My database is hosted on a SQL server through Azure.
A lot of online material I see when I search is for other types of databases or technologies.
I already have the database created.
How can I do this?
EDIT: I want to use ASP.Net Core for the API
but will use Angular to consume it.

I would recommend the following:
Architecture:
If your Angular SPA is Angular 2+ ( Typescript ): Setup a new .NET Core 3+ Web API project with entity framework (since it is a relational database). I would expose all the endpoints using swagger for .net and I would map all those methods on the SPA with a swagger client generator for Typescript.
If your angular SPA is not based on typescript, then I would not install swagger since the frontend is not strongly typed.
Hosting:
If you have an Azure account I would host both on Azure then you wouldn't have to expose your SQL Server to the web or create a VPN for that. Azure has also nice hosting for .NET Core projects.
If you need to make it really scalable
In this case, I would recommend you to publish this ASP.NET Core App building a container and have it running on Kubernetes or other container management server and have a load balancer to have the backend promoted with no downtime.

Related

Can a Worker Service be called and/or used inside an existing ASPNET.Core web project?

I've been reading and learing about the new Worker Service features provided in .Net Core 3.0. I have been using this link from Microsoft: Background tasks with hosted services in ASP.NET Core
What I don't understand is this, can these worker service concepts be introduced into an existing ASPNET Web Project, like a Razor Pages site? Or must you create a new project and then deploy that project as a service using whatever mechanism the host OS proivdes for that?
Yes, you can host any number of hosted services (IHostedService) within ASP.NET Core applications. With version 3, ASP.NET Core uses the generic host (Host.CreateDefaultBuilder) which is the framework that is hosting these hosted services when the application starts. In fact, the ASP.NET Core web application is an IHostedService itself.
To add additional hosted services to your ASP.NET Core application, just register additional hosted services with your service collection, e.g. within the Startup’s ConfigureServices:
services.AddHostedService<MyHostedService>();
That service will then launch together with the ASP.NET Core web server when the application runs.
The Worker SDK that is mentioned in the documentation is actually a subset of the Web SDK that you are using with ASP.NET Core application. Microsoft.NET.Sdk.Worker is basically Microsoft.NET.Sdk.Web without the web-specific stuff like Razor compilation and wwwroot folder stuff. It basically sets up automatic file globbing e.g. for the appsettings.json and does some other useful things that the core Microsoft.NET.Sdk does not have.
Ultimately this means, that when you are using the Web SDK, then you already have everything the Worker SDK offers. So you do not need to specify the Worker SDK just to host additional background services.

Blazor - WebAssemby ASP.NET Core hosted model

There seems to be little documentation on the new WebAssembly ASP.NET Core hosted model. I realise that Blazer WebAssembly model is in preview until May 2020, however, once the latest preview template is installed in Visual Studio 2019, there is the option to use ASP.NET Core hosted.
From what I can gather, this model appears to be a hybrid between the Blazor Server App and the Blazor WebAssembly App hosting models in that in addition to using the client to render in WebAssembly, also employs server technology, e.g. SignalR.
What would be the benefits of using this hosting model?
What would be the benefits of using this hosting model?
In the hosted model, the server will:
serve the client (wasm) Blazor application
typically provide APIs that will be consumed by the client application
In the hosted model, you do not need SignalR to get the Blazor app working

Blazor Server Side and asp.net core AWS serverless lambda application

I have created an aws serverless lambda (asp.net core) application. I am looking at putting a front end on some of my API calls.
I would like to keep with c# and looking at Blazor as an option. I am concerned however that due to the nature of lambda (on demand) that this is incompatible with Blazor.
This is mainly due to the fact that I have read that the client->server connection is "maintained" (via signalR).
Would like clarification on this from someone with experience on the subject matter.
There's 2 Blazor : server-side and client-side (aka wasm).
Server-side Blazor execute on the server and each user's action is sent to the server through a SignalR connection. When a component is render, SignalR send the result to the client and a small js script display it.
Client-side Blazor executes in the browser using Web assembly (WASM). There isn't SignalR connection between the client and the server. That works as any other SPA framework except the fact that is C# code compiled in WASM with mono wasm and not JS.
Server-side is released since ASP.Net core 3.0 and supported by MS.
Client-side is still in preview and should be release mid 2020.
To sum up, you cannot use server-side in server less world.
Blazor Server: There is no definitive solution on AWS for Serverless with Lambda, nor is there a solution with AWS Elastic Beanstalk.
Blazor Web Assembly: If there is a solution here.
The static page (WASM) you host on AWS Amplify.
You must create the backend manually as "AWS Serverless Application" type protection and when it asks you for the type you select "ASP.NET Core Web API" and when publishing it you use the AWS SDK and select it as Lambda.
In this way you will have a hyper scalable application.

How to use asp.net core as a backend authenticate with active directory

I'm using angular2 as a front-end. My Back-end is ASP.NET Core and I am using it as a Restful Web API. How can I authenticate credentials from angular against a local active directory?
Depending on the version of ASP.NET you could implement the ASP.NET Membership or Identity which can connect to AD.
You should easily find various examples of these.
I have recently looked at Auth0, which means you can integrate a variety of ways, front or back-end.
see: https://auth0.com
(not affiliated)

Web Service on Windows Azure?

I am new to Windows Azure and I have a question.
I have:
Web site which deployed to Windows Azure - The web site manage a table (add, edit, delete). I used this guide: Deploying an ASP.NET Web Application to a Windows Azure Web Site and SQL Database
Andorid application & iOS Application (Native Code).
Now, I want the mobile applications to get data (in JSON format) from the web site (and from the DB).
What is the best practice to do that?
I tried to create a Azure (WCF) Service (the project refrenced to the web site project) but I didn't succeded. If this is the way - Is anyone knows a good tutorial to do that?
Is there another option? Maybe from the web site itself?
Thank you very much,
Yuval
If you want to integrate with non-Microsoft technologies I suggest you take a look at the ASP.NET Web API which allows you to build REST services using content negotiation. Content negotiation allows your consumer to specify the format it requires (json, xml, ...).
To host the ASP.NET Web API in a Windows Azure Web Site you should take a look at Carlos' blog, he describes in detail what you need to do to make this work: Creating ASP.NET Web APIs on Azure Web Sites
Have you given ASP.NET Web API a look-see?
http://www.asp.net/web-api