GithubHelp home page GithubHelp logo

lsprado / projetodemo Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 1.6 MB

Projeto de demonstração para integrar com o Azure DevOps

C# 31.36% CSS 6.79% HTML 29.43% JavaScript 1.46% Bicep 28.25% Dockerfile 2.72%

projetodemo's Introduction

ProjetoDemo

Demo project using dotnet core MVC application calling a rest API. This project will be published on Azure WebApp.

Demo Application

The rest api is very simple, just a method to simulate the weather forecast.

Demo Application

src folder

This folder contains all source files for application

Solution

  • ProjetoDemo.WebApi: dotnet 6 rest api
  • ProjetoDemo.WebApp: dotnet 6 web application (mvc)
  • ProjetoDemo.UnitTest: xunit test project

iac folder

This folder contains the bicep files to create Azure environments

  • main.bicep: file for creating azure web app

Running the application locally

  1. Install .NET 6 - https://dotnet.microsoft.com/en-us/download/dotnet/6.0

  2. Install Visual Studio Community or Visual Studio Code - https://visualstudio.microsoft.com/free-developer-offers/

  3. Open the solution file src/ProjetoDemo.sln

  4. Configure Visual Studio to run multiple projects. Right click in ProjetoDemo solution -> Properties -> Startup Project. Select the option Multiple startup projects and select the projects ProjetoDemo.WebApi and ProjetoDemo.WebApp

Solution

  1. Run the application press F5

Publishing the app to Azure Web App

If you want to publish this application to Azure using GitHub actions, follow these steps

Create Azure environment

  1. Create resource group for application
# set variables
$rgName = 'rg-MyProjectDemo'
$location ='eastus'

# login
az login

# set the correct subscription
az account set --subscription '11111111-2222-3333-4444-55555555'
$SubscriptionId = az account show --query id --output tsv

# check the subscription
az account show

# create resource group
az group create --name $rgName --location $location
  1. Create service principal to access the Resource Group with contributor role
az ad sp create-for-rbac --name spnProjetoDemo --role contributor --scopes /subscriptions/$SubscriptionId/resourceGroups/$rgName --sdk-auth
  1. Configure the GitHub secrets, select Settings > Secrets > New secret. Paste the entire JSON output from the Azure CLI command into the secret's value field. Name the secret AZURE_CREDENTIALS.

Create Service Principal Secret

  1. Start the GitHub Action 01-ProjetoDemo_IAC to run the bicep file and create the Azure environment

IAC

  1. Go to the Azure portal and verify that the resources were created successfully.

Azure

Deploy Application

  1. Get the publish profile for Web Api
az webapp deployment list-publishing-profiles --resource-group $rgName --name wapp-MyProjectDemo-api --xml 
  1. Store the publish profile into a GitHub secret, select Settings > Secrets > New secret. Paste the entire XML output from the Azure CLI command into the secret's value field. Name the secret AZURE_PUBLISH_PROFILE_API.

  2. Get the publish profile for Web App

az webapp deployment list-publishing-profiles --resource-group $rgName --name wapp-MyProjectDemo-app --xml 
  1. Store the publish profile into a GitHub secret, select Settings > Secrets > New secret. Paste the entire XML output from the Azure CLI command into the secret's value field. Name the secret AZURE_PUBLISH_PROFILE_APP.

  2. Run the GitHub Action 02-ProjetoDemo_Build_Deploy to build, test and deploy the application to Azure

Deploy

Using Docker

Other option is running this application using container Docker.

Running the application locally using Docker

  1. Generate docker images locally
cd .\src\
docker build -t projetodemo.webapp -f  .\ProjetoDemo.WebApp\Dockerfile .
docker build -t projetodemo.webapi -f  .\ProjetoDemo.WebApi\Dockerfile .
  1. Docker compose locally
cd .\src\
docker-compose -f .\docker-compose.yml up

Solution

Publishing the app to Azure Web App for Containers

  1. Create GibHub secrets for ACR login and ACR password

  2. Runn the GH action 03-ProjetoDemo_IAC_Container to create the Azure Environment

  3. Run the GitHub Action 04-ProjetoDemo_Container to build and push docker images do ACR

Solution

Contribute

Let me know and I'll be glad to invite you !!!, then ...

  • Clone this repository: git clone https://github.com/lsprado/ProjetoDemo.git
  • Create your feature branch: git checkout -b features/my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin features/my-new-feature
  • Submit a pull request 😄

projetodemo's People

Contributors

github-actions[bot] avatar leandromsft avatar lsprado avatar

Watchers

 avatar  avatar

projetodemo's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.