Skip to content

Commit

Permalink
🩹 Fixes Blazor SSR Deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
xxnickles committed Feb 3, 2024
1 parent 617e217 commit 97dde12
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 123 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# This is a basic workflow to help you get started with Actions

name: Functions Deployment
name: Backend Deployment

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the 'main' branch
push:
paths-ignore:
- "src/AnimeFeedManager.Web**"
- "src/AnimeFeedManager.WebApp**"
- "**/*.md"
branches:
- main
pull_request:
paths-ignore:
- "src/AnimeFeedManager.Web**"
- "src/AnimeFeedManager.WebApp**"
- "**/*.md"
types: [opened, synchronize, reopened, closed]
branches:
Expand Down Expand Up @@ -86,6 +84,70 @@ jobs:
app-name: ${{ steps.infrastructure.outputs.appname }}
package: "${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output"

build-blazor-ssr-app:

needs: build-and-deploy-functions
runs-on: ubuntu-latest
steps:
# Checkout the repo
- uses: actions/checkout@main
- uses: azure/login@v1.6.1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

# Deploys infrastructure
- name: Deploy Azure Infrastructure
uses: Azure/arm-deploy@v1
id: infrastructure
with:
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }}
resourceGroupName: ${{ secrets.AZURE_RG }}
template: ./deployment/main-blazor.bicep
parameters: passwordlessApiKey=${{ secrets.PASSWORDLESS_APIKEY }} passwordlessApiSecret=${{ secrets.PASSWORDLESS_APISECRET }}
failOnStdErr: false

- name: "Set Output as Env Var"
run: echo "AZURE_WEBAPP_NAME=${{ steps.infrastructure.outputs.appname }}" >> $GITHUB_ENV

# Setup node.js for tailwind
- name: Setup Node lts
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: "npm install, build, and test"
run: |
npm install
npx tailwindcss -i ./Styles/app.css -o ./wwwroot/app.css --minify
working-directory: ${{ env.APP_PATH }}

# Setup .NET Core SDK
- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

# Run dotnet build and publish
- name: dotnet build and publish
shell: bash
run: |
pushd '${{ env.APP_PATH }}'
dotnet restore
dotnet build --configuration Release
dotnet publish -c Release --property:PublishDir='${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp'
popd
# Deploy to Azure Web apps
- name: "Run Azure webapp deploy action using publish profile credentials"
uses: azure/webapps-deploy@v3
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name
package: "${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp"

- name: logout
run: |
az logout
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
Expand Down
91 changes: 0 additions & 91 deletions .github/workflows/amf-ssr-site.yml

This file was deleted.

43 changes: 17 additions & 26 deletions deployment/blazor-app.bicep
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
@description('Optional Git Repo URL')
param repoUrl string = ' '

@description('Storage Account Name')
param storageAccountName string

@description('Instrumentation Key')
param instrumentationKey string


@secure()
param passwordlessApiKey string

Expand All @@ -22,33 +18,27 @@ var webAppHostingPlanName = 'afm-blazor-hosting-plan'
var keyVaultName = 'afm-key-vault'
var managedIdentityName = 'afm-managed-identity'

resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' existing = {
name: storageAccountName
scope: resourceGroup()
}

resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = {
name: managedIdentityName
location: location
}

// Create the role assignments for Azure Storage
// Create the role assignments for Azure Storage. Doesn't work as you will need to have some werid permisions

var roleDefinitionIds = [
'974c5e8b-45b9-4653-ba55-5f855dd0fb88' //Storage Queue Data Contributor
'0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa' //Storage Table Data Contributor
'ba92f5b4-2d11-453d-a403-e96b0029c9fe' //Storage Blob Data Contributor
]
// var roleDefinitionIds = [
// '974c5e8b-45b9-4653-ba55-5f855dd0fb88' //Storage Queue Data Contributor
// '0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa' //Storage Table Data Contributor
// 'ba92f5b4-2d11-453d-a403-e96b0029c9fe' //Storage Blob Data Contributor
// ]

resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = [for roleDefinitionId in roleDefinitionIds: {
scope: storageAccount
name: guid(storageAccount.id, managedIdentity.id, roleDefinitionId)
properties: {
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleDefinitionId)
principalId: managedIdentity.id
principalType: managedIdentity.type
}
}]
// resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = [for roleDefinitionId in roleDefinitionIds: {
// scope: storageAccount
// name: guid(storageAccount.id, managedIdentity.id, roleDefinitionId)
// properties: {
// roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleDefinitionId)
// principalId: managedIdentity.id
// principalType: managedIdentity.type
// }
// }]



Expand All @@ -68,6 +58,7 @@ resource keyVault 'Microsoft.KeyVault/vaults@2023-07-01' = {
permissions: {
secrets: [
'get'
'list'
]
}
}
Expand Down
1 change: 0 additions & 1 deletion deployment/main-blazor.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module blazor './blazor-app.bicep' = {
params: {
location: location
instrumentationKey: common.outputs.instrumentationKey
storageAccountName: common.outputs.storageAccountName
passwordlessApiKey: passwordlessApiKey
passwordlessApiSecret: passwordlessApiSecret
repoUrl: repoUrl
Expand Down

0 comments on commit 97dde12

Please sign in to comment.