Skip to content

Commit

Permalink
Setup Azure infrastructure with Bicep and GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
akbast committed Jun 7, 2024
1 parent 92ec0b8 commit 209a8ed
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/deploy_infra.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Deploy Infrastructure

on:
push:
branches:
- main

jobs:
deploy_infra:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Deploy Bicep files
run: |
az deployment group create --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} --template-file ./infra/main.bicep --parameters appServiceName=${{ secrets.APP_SERVICE_NAME }} storageAccountName=${{ secrets.STORAGE_ACCOUNT_NAME }}
21 changes: 21 additions & 0 deletions infra/appservice.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
param appServiceName string
param location string = 'eastus'
param appServicePlanId string

resource appService 'Microsoft.Web/sites@2021-02-01' = {
name: appServiceName
location: location
kind: 'app'
properties: {
serverFarmId: appServicePlanId
httpsOnly: true
}
siteConfig: {
appSettings: [
{
name: 'WEBSITE_NODE_DEFAULT_VERSION'
value: '10.14.1'
}
]
}
}
21 changes: 21 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
targetScope = 'resourceGroup'

resource appService 'Microsoft.Web/sites@2021-02-01' = {
name: 'appServiceName'
location: 'location'
properties: {
serverFarmId: 'appServicePlanId'
}
}

resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = {
name: 'storageAccountName'
location: 'location'
kind: 'StorageV2'
sku: {
name: 'Standard_LRS'
}
properties: {
accessTier: 'Hot'
}
}
14 changes: 14 additions & 0 deletions infra/storageaccount.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
param storageAccountName string
param location string = 'eastus'

resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = {
name: storageAccountName
location: location
kind: 'StorageV2'
sku: {
name: 'Standard_LRS'
}
properties: {
accessTier: 'Hot'
}
}

0 comments on commit 209a8ed

Please sign in to comment.