From 10aa610661c1cce6ea3cfee420f901330c179d0b Mon Sep 17 00:00:00 2001 From: System Administrator Date: Tue, 22 Oct 2024 15:41:17 -0400 Subject: [PATCH 01/13] removed workflow --- .github/workflows/pages.yml | 62 ------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 .github/workflows/pages.yml diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml deleted file mode 100644 index cedae546..00000000 --- a/.github/workflows/pages.yml +++ /dev/null @@ -1,62 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# Sample workflow for building and deploying a Jekyll site to GitHub Pages -name: Deploy Jekyll site to Pages - -on: - push: - branches: ["main"] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow one concurrent deployment -concurrency: - group: "pages" - cancel-in-progress: true - -jobs: - # Build job - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.1' # Not needed with a .ruby-version file - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - cache-version: 0 # Increment this number if you need to re-download cached gems - - name: Setup Pages - id: pages - uses: actions/configure-pages@v2 - - name: Build with Jekyll - # Outputs to the './_site' directory by default - run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" - env: - JEKYLL_ENV: production - - name: Upload artifact - # Automatically uploads an artifact from the './_site' directory by default - uses: actions/upload-pages-artifact@v1 - - # Deployment job - deploy: - environment: - name: github-pages - url: "${{ steps.deployment.outputs.page_url }}" - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 From 4ae300bf32520cb0e13b2b03bcff2d94cb193e25 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Tue, 22 Oct 2024 16:11:46 -0400 Subject: [PATCH 02/13] Create first-workflow.yml --- .github/workflows/first-workflow.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/first-workflow.yml diff --git a/.github/workflows/first-workflow.yml b/.github/workflows/first-workflow.yml new file mode 100644 index 00000000..f976f401 --- /dev/null +++ b/.github/workflows/first-workflow.yml @@ -0,0 +1,27 @@ +name: First Workflow + +on: + workflow_dispatch: + issues: + types: [opened] + +jobs: + job1: + runs-on: ubuntu-latest + steps: + - name: Step one + run: echo "Log from step one" + env: + VARIABLE_NAME: value + - name: Step two + run: echo "Log from step two" + + job2: + needs: job1 + runs-on: ubuntu-latest + steps: + - name: Cowsays + uses: mscoutermarsh/cowsays-action@master + with: + text: 'Ready for prod--ship it!' + color: 'magenta' From 179822a27fe62c36b4fdf3932c29cd14388b2071 Mon Sep 17 00:00:00 2001 From: System Administrator Date: Tue, 22 Oct 2024 16:35:11 -0400 Subject: [PATCH 03/13] updated legth. resolve #3 --- src/Application/src/RazorPagesTestSample/Data/Message.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Application/src/RazorPagesTestSample/Data/Message.cs b/src/Application/src/RazorPagesTestSample/Data/Message.cs index ea99cbd6..290fb2a8 100644 --- a/src/Application/src/RazorPagesTestSample/Data/Message.cs +++ b/src/Application/src/RazorPagesTestSample/Data/Message.cs @@ -9,7 +9,7 @@ public class Message [Required] [DataType(DataType.Text)] - [StringLength(200, ErrorMessage = "There's a 200 character limit on messages. Please shorten your message.")] + [StringLength(250, ErrorMessage = "There's a 200 character limit on messages. Please shorten your message.")] public string Text { get; set; } } #endregion From b3c4c43d88b869a58123df111406226da55d081a Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 23 Oct 2024 12:16:05 -0400 Subject: [PATCH 04/13] Create deploy.yml --- .github/workflows/deploy.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..2de39864 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,35 @@ +name: Azure Bicep + +on: + workflow_dispatch + +env: + targetEnv: dev + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write + steps: + # Checkout code + - uses: actions/checkout@main + + # Log into Azure + - uses: azure/login@v2.1.1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + enable-AzPSSession: true + + # Deploy ARM template + - name: Run ARM deploy + uses: azure/arm-deploy@v1 + with: + subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + resourceGroupName: ${{ secrets.AZURE_RG }} + template: ./src/InfrastructureAsCode/main.bicep + parameters: environment=${{ env.targetEnv }} From fc108d8a9063585f14a34ff1a120a61d0c8fb6ee Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 23 Oct 2024 12:21:20 -0400 Subject: [PATCH 05/13] Update deploy.yml --- .github/workflows/deploy.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2de39864..86735530 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,10 +1,15 @@ name: Azure Bicep on: - workflow_dispatch - -env: - targetEnv: dev + workflow_dispatch: + inputs: + appenv: + type: choice + description: Choose the target environment + options: + - dev + - test + - prod jobs: build-and-deploy: @@ -18,7 +23,7 @@ jobs: - uses: actions/checkout@main # Log into Azure - - uses: azure/login@v2.1.1 + - uses: azure/login@v1 with: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} @@ -31,5 +36,5 @@ jobs: with: subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }} resourceGroupName: ${{ secrets.AZURE_RG }} - template: ./src/InfrastructureAsCode/main.bicep - parameters: environment=${{ env.targetEnv }} + template: ./InfrastructureAsCode/main.bicep + parameters: environment=${{ github.event.inputs.appenv }} From 27374b66cdcc928d923b3d500ce02db645c782fe Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 23 Oct 2024 12:50:22 -0400 Subject: [PATCH 06/13] Update deploy.yml --- .github/workflows/deploy.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 86735530..6b993805 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,16 +25,16 @@ jobs: # Log into Azure - uses: azure/login@v1 with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + client-id: ${{ env.AZURE_CLIENT_ID }} + tenant-id: ${{ env.AZURE_TENANT_ID }} + subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }} enable-AzPSSession: true # Deploy ARM template - name: Run ARM deploy uses: azure/arm-deploy@v1 with: - subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - resourceGroupName: ${{ secrets.AZURE_RG }} + subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }} + resourceGroupName: ${{ env.AZURE_RG }} template: ./InfrastructureAsCode/main.bicep parameters: environment=${{ github.event.inputs.appenv }} From bfaa0f0c1804551b643598b45eeff38dbb1fd47f Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 23 Oct 2024 12:55:01 -0400 Subject: [PATCH 07/13] Update deploy.yml --- .github/workflows/deploy.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6b993805..a3cf4872 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,16 +25,16 @@ jobs: # Log into Azure - uses: azure/login@v1 with: - client-id: ${{ env.AZURE_CLIENT_ID }} - tenant-id: ${{ env.AZURE_TENANT_ID }} - subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }} + client-id: ${{ vars.AZURE_CLIENT_ID }} + tenant-id: ${{ vars.AZURE_TENANT_ID }} + subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }} enable-AzPSSession: true # Deploy ARM template - name: Run ARM deploy uses: azure/arm-deploy@v1 with: - subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }} - resourceGroupName: ${{ env.AZURE_RG }} + subscriptionId: ${{ vars.AZURE_SUBSCRIPTION_ID }} + resourceGroupName: ${{ vars.AZURE_RG }} template: ./InfrastructureAsCode/main.bicep parameters: environment=${{ github.event.inputs.appenv }} From cfa86bff349e4b6fe6be1a848f37117876027963 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 23 Oct 2024 13:16:34 -0400 Subject: [PATCH 08/13] Update deploy.yml --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a3cf4872..8d3287db 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -36,5 +36,5 @@ jobs: with: subscriptionId: ${{ vars.AZURE_SUBSCRIPTION_ID }} resourceGroupName: ${{ vars.AZURE_RG }} - template: ./InfrastructureAsCode/main.bicep + template: ./src/InfrastructureAsCode/main.bicep parameters: environment=${{ github.event.inputs.appenv }} From 9309bded01957daa91cafa3653164d1ab13f6f51 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 23 Oct 2024 13:23:15 -0400 Subject: [PATCH 09/13] Update main.bicep --- src/InfrastructureAsCode/main.bicep | 92 ++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/src/InfrastructureAsCode/main.bicep b/src/InfrastructureAsCode/main.bicep index 6dc69618..d8e740d2 100644 --- a/src/InfrastructureAsCode/main.bicep +++ b/src/InfrastructureAsCode/main.bicep @@ -8,10 +8,98 @@ var webAppName = '${uniqueString(resourceGroup().id)}-${environment}' var appServicePlanName = '${uniqueString(resourceGroup().id)}-mpnp-asp' var logAnalyticsName = '${uniqueString(resourceGroup().id)}-mpnp-la' var appInsightsName = '${uniqueString(resourceGroup().id)}-mpnp-ai' -var sku = 'S1' +var sku = 'P0V3' var registryName = '${uniqueString(resourceGroup().id)}mpnpreg' var registrySku = 'Standard' var imageName = 'techexcel/dotnetcoreapp' var startupCommand = '' -// TODO: complete this script + +resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2021-12-01-preview' = { + name: logAnalyticsName + location: location + properties: { + sku: { + name: 'PerGB2018' + } + retentionInDays: 90 + workspaceCapping: { + dailyQuotaGb: 1 + } + } +} + +resource appInsights 'Microsoft.Insights/components@2020-02-02-preview' = { + name: appInsightsName + location: location + kind: 'web' + properties: { + Application_Type: 'web' + WorkspaceResourceId: logAnalyticsWorkspace.id + } +} + +resource containerRegistry 'Microsoft.ContainerRegistry/registries@2020-11-01-preview' = { + name: registryName + location: location + sku: { + name: registrySku + } + properties: { + adminUserEnabled: true + } +} + +resource appServicePlan 'Microsoft.Web/serverFarms@2022-09-01' = { + name: appServicePlanName + location: location + kind: 'linux' + properties: { + reserved: true + } + sku: { + name: sku + } +} + +resource appServiceApp 'Microsoft.Web/sites@2020-12-01' = { + name: webAppName + location: location + properties: { + serverFarmId: appServicePlan.id + httpsOnly: true + clientAffinityEnabled: false + siteConfig: { + linuxFxVersion: 'DOCKER|${containerRegistry.name}.azurecr.io/${uniqueString(resourceGroup().id)}/${imageName}' + http20Enabled: true + minTlsVersion: '1.2' + appCommandLine: startupCommand + appSettings: [ + { + name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE' + value: 'false' + } + { + name: 'DOCKER_REGISTRY_SERVER_URL' + value: 'https://${containerRegistry.name}.azurecr.io' + } + { + name: 'DOCKER_REGISTRY_SERVER_USERNAME' + value: containerRegistry.name + } + { + name: 'DOCKER_REGISTRY_SERVER_PASSWORD' + value: containerRegistry.listCredentials().passwords[0].value + } + { + name: 'APPINSIGHTS_INSTRUMENTATIONKEY' + value: appInsights.properties.InstrumentationKey + } + ] + } + } +} + +output application_name string = appServiceApp.name +output application_url string = appServiceApp.properties.hostNames[0] +output container_registry_name string = containerRegistry.name From 665bb9e3c0ae578a35e05cab076d3c77e53a43e2 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 23 Oct 2024 13:42:42 -0400 Subject: [PATCH 10/13] Create dotnet-deploy-3.yml --- .github/workflows/dotnet-deploy-3.yml | 123 ++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 .github/workflows/dotnet-deploy-3.yml diff --git a/.github/workflows/dotnet-deploy-3.yml b/.github/workflows/dotnet-deploy-3.yml new file mode 100644 index 00000000..f65668a8 --- /dev/null +++ b/.github/workflows/dotnet-deploy-3.yml @@ -0,0 +1,123 @@ +name: .NET CI + +env: + registryName: bw2wpkzuzoaummpnpreg.azurecr.io + repositoryName: techexcel/dotnetcoreapp + dockerFolderPath: ./src/Application/src/RazorPagesTestSample + tag: ${{github.run_number}} + +on: + push: + branches: [ main ] + paths: src/Application/** + pull_request: + branches: [ main ] + paths: src/Application/** + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0 + + - name: Restore dependencies + run: dotnet restore ./src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj + - name: Build + run: dotnet build --no-restore ./src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj + - name: Test + run: dotnet test --no-build --verbosity normal ./src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj + + dockerBuildPush: + runs-on: ubuntu-latest + needs: build + + steps: + - uses: actions/checkout@v3 + + - name: Docker Login + # You may pin to the exact commit or the version. + # uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + uses: docker/login-action@v1.9.0 + with: + # Server address of Docker registry. If not set then will default to Docker Hub + registry: ${{ vars.ACR_LOGIN_SERVER }} + # Username used to log against the Docker registry + username: ${{ vars.ACR_USERNAME }} + # Password or personal access token used to log against the Docker registry + password: ${{ secrets.ACR_PASSWORD }} + # Log out from the Docker registry at the end of a job + logout: true + + - name: Docker Build + run: docker build -t $registryName/$repositoryName:$tag --build-arg build_version=$tag $dockerFolderPath + + - name: Docker Push + run: docker push $registryName/$repositoryName:$tag + + deploy-to-dev: + + runs-on: ubuntu-latest + needs: dockerBuildPush + environment: + name: dev + url: https://{your_prefix}-dev.azurewebsites.net/ + + steps: + - name: 'Login via Azure CLI' + uses: azure/login@v2.1.1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - uses: azure/webapps-deploy@v2 + with: + app-name: 'bw2wpkzuzoaum-dev' + images: bw2wpkzuzoaummpnpreg.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}} + + deploy-to-test: + + runs-on: ubuntu-latest + needs: deploy-to-dev + environment: + name: test + url: https://bw2wpkzuzoaum-test.azurewebsites.net/ + + steps: + - uses: actions/checkout@v3 + + - name: 'Login via Azure CLI' + uses: azure/login@v2.1.1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - uses: azure/webapps-deploy@v2 + with: + app-name: 'bw2wpkzuzoaum-test' + images: bw2wpkzuzoaummpnpreg.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}} + + deploy-to-prod: + + runs-on: ubuntu-latest + needs: deploy-to-test + environment: + name: prod + url: https://bw2wpkzuzoaum-prod.azurewebsites.net/ + + steps: + - uses: actions/checkout@v3 + + - name: 'Login via Azure CLI' + uses: azure/login@v2.1.1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - uses: azure/webapps-deploy@v2 + with: + app-name: 'bw2wpkzuzoaum-prod' + images: bw2wpkzuzoaummpnpreg.azurecr.io/techexcel/dotnetcoreapp:${{github.run_number}} From 07a18abf5d367fd9024c3a3b55da6c30b3748093 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 23 Oct 2024 13:45:15 -0400 Subject: [PATCH 11/13] Update dotnet-deploy-3.yml --- .github/workflows/dotnet-deploy-3.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-deploy-3.yml b/.github/workflows/dotnet-deploy-3.yml index f65668a8..933f58c2 100644 --- a/.github/workflows/dotnet-deploy-3.yml +++ b/.github/workflows/dotnet-deploy-3.yml @@ -67,7 +67,7 @@ jobs: needs: dockerBuildPush environment: name: dev - url: https://{your_prefix}-dev.azurewebsites.net/ + url: https://bw2wpkzuzoaum-dev.azurewebsites.net/ steps: - name: 'Login via Azure CLI' From 60a8413d65c3bc3c6cc290426b4bcc25ad0482ae Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 23 Oct 2024 13:50:22 -0400 Subject: [PATCH 12/13] Create Dockerfile --- .../src/RazorPagesTestSample/Dockerfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/Application/src/RazorPagesTestSample/Dockerfile diff --git a/src/Application/src/RazorPagesTestSample/Dockerfile b/src/Application/src/RazorPagesTestSample/Dockerfile new file mode 100644 index 00000000..833554c7 --- /dev/null +++ b/src/Application/src/RazorPagesTestSample/Dockerfile @@ -0,0 +1,18 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env +WORKDIR /app + +# Copy csproj and restore as distinct layers +COPY *.csproj ./ +RUN dotnet restore + +# Copy everything else and build +COPY . ./ +RUN dotnet publish -c Release -o out + +# Build runtime image +FROM mcr.microsoft.com/dotnet/aspnet:8.0 +WORKDIR /app +COPY --from=build-env /app/out . +# Default ASP.NET port changed with .NET 8.0 +ENV ASPNETCORE_HTTP_PORTS=80 +ENTRYPOINT ["dotnet", "RazorPagesTestSample.dll"] From 256ebc2a763c46d6aebd451379c674fd92ec354c Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 23 Oct 2024 15:16:26 -0400 Subject: [PATCH 13/13] Create CODEOWNERS --- CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000..bc226f37 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* vdronov@microsoft.com