Skip to content

Latest commit

 

History

171 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BlogPost

This repository can be used to build the sample project to use in training, such as with Azure DevOps certifications.

Prep your enviornment

  • Install latest version of .NET Core
  • Install PowerShell Core
  • Open PowerShell Core
    • Check .NET Core version by running the following command: dotnet --version
    • Ensure Entity Framework Core is installed by running the following command: dotnet ef

Set-up PostgreSQL on Docker This code sample uses PostgreSQL as the backend database. The easiest way to run the sample database is via a Docker

  • Install Docker Community Edition and ensure the docker engine is running by running the following command: docker run hello-world
  • Install PgAdmin which will install the psql command-line tools which you can use later
  • Execute the following shell script in the repository to create the docker container: src/ShellScripts/blog-pg-container-initialize.sh. If on Windows, then copy the contents of the file and execute.
  • To see the running container, execute the following command: docker ps
  • Note the IP of the machine where the container is running so you can use this information to connect to the PostgreSQL instance on Port 5433

Create Database

  • Clone this repository
  • Once the environment is cloned, In PowerShell Core navigate to the Blog/src/Blog.PostgresSQL.EF directory
  • Open the appSettings.config file
  • In the line "blog": "host=<your server>;port=<your port>database=blog;username=postgres;password=postgres"
    • Change the host entry to point to the IP where the PostgreSQL DB is running
    • Change the port entry to "5433" (this is the port set by the docker command above)
  • In PowerShell Core, stay in the Blog/src/Blog.PostgreSQL.EF directory and execute the command: dotnet ef database update. This command will create the database blog in PostreSQL database
  • In PowerShell Core
    • Navigate to the Blog/src/Blog.PostgreSQL/post-deploymentscripts directory
    • Execue the following psql command psql -h <your host> -p 5433 -d blog -f blog_entry_insert.sql
    • Sample rows are entered in the blog_entry and blog_post tables

Test Api

  • In PowerShell Core, navigate to the Blog/src/Blog.Web directory
  • Open in Visual Studio Code by entering the command: code .
  • Once open in code, open the Blog/src/Blog.Web/appSettings.json file and set the host and port settings to the values you set above in the Blog/src/Blog.PostgreSQL.EF/appSettings.json file
  • Debug the Blog.Web project and enter the following Url in the browser

Updates

2020-11-26

About

This is sample project

Resources

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages