GitHub repository for AWS CodeStar ASP.NET Core web service token-service.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
AWS
Core
CoreTest
InMemory
InMemoryTest
Models
ModelsTest
TokenService
TokenServiceTest
scripts
.dockerignore
.gitignore
README.md
TokenService.sln
_config.yml
appspec.yml
buildspec.yml
docker-compose.ci.build.yml
docker-compose.dcproj
docker-compose.dcproj.user
docker-compose.override.yml
docker-compose.yml

README.md

This project is not yet ready for any type of public consumption

Token Service

This application will eventually be a single use token service.

Endpoints

The Token Service implements a set of REST endpoints to create and validate tokens.

Endpoint Documentation provided with Swagger

Use the following endpoints to see API documentation.

  • GET /swagger/
  • GET /swagger/v1/swagger.json
Token Endpoints

This service implements the following endpoints. See the swagger documentation for request and response specifications

  • POST /api/v1/Token/Generate
  • POST /api/v1/Token/Validate

Running this Application

This is a standard .Net Core ASP web application. As such it can be run from inside Visual Studio using the normal "default project" way. The project also includes docker files that make it easy to run the project inside a docker container.

In IIS Express via VS2017

The Token Service can be debugged while running inside IIS Express. You can tell when you are running / debugging in IIS because the console output appears inside the Output pane inside Visual Studio.

  1. Make sure Token Service is the active project in the project drop down.
  2. Select IIS Express in the run dropdown that contains the green play icon
  3. Press the play icon, F5, Ctrl-F5 or use the Debug menu in the menu bar
  4. VS will switch to debug mode and run the application
    1. VS will launch a browser if the Launch Browser select box is enabled in the Token Service project file.
As a Project via VS2017

The Token Service is marked as the default project. This means you can run it via F5 or Ctrl-F5. You can tell when you are running in this mode because the console output appears in a standalone window.

  1. Make sure Token Service is the active project in the toolbar dropdown.
  2. Select Token Service in the run drop down that contains the green Play icon.
  3. Press the play icon, F5, Ctrl-F5 or use the Debug menu in the menu bar
  4. VS will switch to debug mode and run the application
    1. VS will launch a browser if the Launch Browser select box is enabled in the Token Service project file.
DotNet Core embedded web server via Command Line
  1. Open a powershell or other command line prompt.
    1. I typically use the Git Shell installed with the GitHub application
  2. CD into the TokenService project
  3. type dotnet run to run the project
    1. Console output will provide the browser connection string to connect to the service
    2. See the interesting links for more info on the dot net CLI
Docker via VS2017

This requires that Linux docker containers are enabled and configured.

See the interesting links for more details on how to run this from inside VS2017

  1. Highlight the docker-compose node in the Solution explorer
  2. Right mouse and click on start new instance
  3. Visual Studio (VS) will attach to that process.
    1. You can detach from the running docker by clicking on the red square in the debug bar The docker process will continue to run after disconnect

I was unable to get docker to appear in the debug drop down in the tool bar to run ith without project right mouse

You should be able to see and manipulate the image from the Docker command line

  1. docker ps to see the process and Container ID
  2. docker stop <container id> to remove the process
Docker via command line

<to be documented>

Docker Configuration

  1. You are running Windows 10+ or Windows Server with Docker enabled
  2. Docker is configured for Linux Containers
  3. Your user id is added to the docker-users group. Docker will provide instructions if you are not a member of this group.
  4. Docker file sharing for deployment is enabled. Visual Studio / Docker will provide instructions / make this change if it is not enabled.

Swagger and XML documentation

Swagger is configured to expose the generated XML documentation for the REST endpoints. This means the system must copy TokenService.xml into the correct directory as part of the build process so that it can then be copied to the server.

AWS AMI EC2 Instances have case sensitive file systems. This means that the XML file system location must be cased correctly. That file path includes the Configurat value, Debug or Release. The case of the first character in that is important because it is important in the file path buildspec.yml must set the -c configuration value to Debug or Release where the first eltter is capitalized. Failure to do this results in deployment failure due to the loss of the xml documentation needed by Swagger

Interesting Links

I found these links useful while trying to understand how to use Docker with .Net Core 2.0 and with Visual Studio 2017


This section generated by original AWS CodeStar template.

  • The default project AspNetCoreWebService has been renamed to TokenService.
    • scripts/start_service was modified to point at TokenService instead of AspNetCoreWebService
  • This project has been updated to DotNet Core 2.0
    • The AWS Console CodeDeploy pipeline section Environment: How to build also had to be updated to use core-2.0

The following documentation here has not been modified to reflect this.

AWS CodeStar Sample ASP.NET Core Web Service

This sample code helps get you started with a simple ASP.NET Core web service deployed by AWS CodeDeploy to an Amazon EC2 server.

What's Here

This sample includes:

  • README.md - this file
  • appspec.yml - this file is used by AWS CodeDeploy when deploying the web service to EC2
  • buildspec.yml - this file is used by AWS CodeBuild to build the web service
  • AspNetCoreWebService/ - this directory contains your ASP.NET Core service project files
  • scripts/ - this directory contains scripts used by AWS CodeDeploy when installing and deploying your service on the Amazon EC2 instance

Getting Started

These directions assume you want to develop on your local computer, and not from the Amazon EC2 instance itself. If you're on the Amazon EC2 instance, the virtual environment is already set up for you, and you can start working on the code.

To work on the sample code, you'll need to clone your project's repository to your local computer. If you haven't, do that first. You can find instructions in the AWS CodeStar user guide.

  1. Install dotnet. See https://www.microsoft.com/net/core

  2. Build the service.

     $ cd AspNetCoreWebService
     $ dotnet restore
     $ dotnet build
    
  3. Run Kestrel server.

     $ dotnet run
    
  4. Open http://localhost:5000/ in a web browser to view your service.

What Do I Do Next?

Once you have a virtual environment running, you can start making changes to the sample ASP.NET Core web service. We suggest making a small change to /AspNetCoreWebservice/Controller/HelloController.cs first, so you can see how changes pushed to your project's repository are automatically picked up by your project pipeline and deployed to the Amazon EC2 instance. (You can watch the pipeline progress on your project dashboard.) Once you've seen how that works, start developing your own code, and have fun!

Learn more about AWS CodeStar by reading the user guide. Ask questions or make suggestions on our forum.

User Guide: http://docs.aws.amazon.com/codestar/latest/userguide/welcome.html

Forum: https://forums.aws.amazon.com/forum.jspa?forumID=248