Skip to content

Commit

Permalink
Cleanup pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeGinnivan committed Jul 22, 2024
1 parent df947ad commit 010f31d
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 55 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
on:
workflow_dispatch:
push:
branches:
- main

jobs:
deploy-development:
uses: ./.github/workflows/deploy.yml
secrets: inherit
with:
AZURE_ENV_NAME: dev
12 changes: 12 additions & 0 deletions .github/workflows/deploy-prd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
on:
workflow_dispatch:
push:
branches:
- main

jobs:
deploy-development:
uses: ./.github/workflows/deploy.yml
secrets: inherit
with:
AZURE_ENV_NAME: prd
46 changes: 18 additions & 28 deletions .github/workflows/azure-dev.yml → .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
on:
workflow_dispatch:
push:
# Run when commits are pushed to mainline branch (main or master)
# Set this to the mainline branch you are using
branches:
- main
- master
workflow_call:
inputs:
AZURE_ENV_NAME:
required: true
type: string
secrets:
AUTH_CLIENT_ID:
required: false

AUTH_CLIENT_SECRET:
required: false

# GitHub Actions workflow to deploy to Azure using azd
# To configure required secrets for connecting to Azure, simply run `azd pipeline config`
Expand All @@ -19,12 +23,14 @@ permissions:
jobs:
build:
runs-on: ubuntu-latest
environment: ${{ inputs.AZURE_ENV_NAME }}
env:
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID}}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID}}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID}}
AZURE_ENV_NAME: ${{ inputs.AZURE_ENV_NAME }}
AZURE_LOCATION: australiaeast

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -47,32 +53,16 @@ jobs:
run: pnpm install

- name: Log in with Azure (Federated Credentials)
if: ${{ env.AZURE_CLIENT_ID != '' }}
run: |
azd auth login `
--client-id "$Env:AZURE_CLIENT_ID" `
--federated-credential-provider "github" `
--tenant-id "$Env:AZURE_TENANT_ID"
shell: pwsh

- name: Log in with Azure (Client Credentials)
if: ${{ env.AZURE_CREDENTIALS != '' }}
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
azd auth login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
shell: pwsh
env:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}

- name: Provision Infrastructure
run: azd provision --no-prompt
env:
AZD_INITIAL_ENVIRONMENT_CONFIG: ${{ secrets.AZD_INITIAL_ENVIRONMENT_CONFIG }}
AUTH_CLIENT_ID: ${{ secrets.AUTH_CLIENT_ID }}
AUTH_CLIENT_SECRET: ${{ secrets.AUTH_CLIENT_SECRET }}

Expand Down
4 changes: 2 additions & 2 deletions azure.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json

name: ddd-2024
name: ddd
metadata:
template: [email protected]

services:
ddd-2024:
ddd:
project: .
host: containerapp
language: ts
Expand Down
File renamed without changes.
31 changes: 16 additions & 15 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ param environmentName string
@description('Primary location for all resources')
param location string

param ddd2024Exists bool
param dddExists bool
@secure()
param ddd2024Definition object
param dddDefinition object

param authClientId string
@secure()
Expand All @@ -31,9 +31,10 @@ var tags = {

var abbrs = loadJsonContent('./abbreviations.json')
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
var prefix = 'dddperth'

resource rg 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: 'rg-${environmentName}'
name: '${prefix}-rg-${environmentName}'
location: location
tags: tags
}
Expand All @@ -43,16 +44,16 @@ module monitoring './shared/monitoring.bicep' = {
params: {
location: location
tags: tags
logAnalyticsName: '${abbrs.operationalInsightsWorkspaces}${resourceToken}'
applicationInsightsName: '${abbrs.insightsComponents}${resourceToken}'
logAnalyticsName: '${prefix}-${abbrs.operationalInsightsWorkspaces}${resourceToken}'
applicationInsightsName: '${prefix}-${abbrs.insightsComponents}${resourceToken}'
}
scope: rg
}

module dashboard './shared/dashboard-web.bicep' = {
name: 'dashboard'
params: {
name: '${abbrs.portalDashboards}${resourceToken}'
name: '${prefix}-${abbrs.portalDashboards}${resourceToken}'
applicationInsightsName: monitoring.outputs.applicationInsightsName
location: location
tags: tags
Expand All @@ -65,7 +66,7 @@ module registry './shared/registry.bicep' = {
params: {
location: location
tags: tags
name: '${abbrs.containerRegistryRegistries}${resourceToken}'
name: '${prefix}-${abbrs.containerRegistryRegistries}${resourceToken}'
}
scope: rg
}
Expand All @@ -75,7 +76,7 @@ module keyVault './shared/keyvault.bicep' = {
params: {
location: location
tags: tags
name: '${abbrs.keyVaultVaults}${resourceToken}'
name: '${prefix}-${abbrs.keyVaultVaults}${resourceToken}'
principalId: principalId
}
scope: rg
Expand All @@ -84,7 +85,7 @@ module keyVault './shared/keyvault.bicep' = {
module appsEnv './shared/apps-env.bicep' = {
name: 'apps-env'
params: {
name: '${abbrs.appManagedEnvironments}${resourceToken}'
name: '${prefix}-${abbrs.appManagedEnvironments}${resourceToken}'
location: location
tags: tags
applicationInsightsName: monitoring.outputs.applicationInsightsName
Expand All @@ -93,18 +94,18 @@ module appsEnv './shared/apps-env.bicep' = {
scope: rg
}

module ddd2024 './app/ddd-2024.bicep' = {
name: 'ddd-2024'
module ddd './app/ddd.bicep' = {
name: 'ddd'
params: {
name: '${abbrs.appContainerApps}ddd-2024-${resourceToken}'
name: '${prefix}-${abbrs.appContainerApps}ddd-${resourceToken}'
location: location
tags: tags
identityName: '${abbrs.managedIdentityUserAssignedIdentities}ddd-2024-${resourceToken}'
identityName: '${prefix}-${abbrs.managedIdentityUserAssignedIdentities}ddd-${resourceToken}'
applicationInsightsName: monitoring.outputs.applicationInsightsName
containerAppsEnvironmentName: appsEnv.outputs.name
containerRegistryName: registry.outputs.name
exists: ddd2024Exists
appDefinition: ddd2024Definition
exists: dddExists
appDefinition: dddDefinition
environment: environmentName
authClientId: authClientId
authClientSecret: authClientSecret
Expand Down
20 changes: 10 additions & 10 deletions next-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Configure environment variables for running services by updating `settings` in [
### Configure CI/CD pipeline

1. Create a workflow pipeline file locally. The following starters are available:
- [Deploy with GitHub Actions](https://github.com/Azure-Samples/azd-starter-bicep/blob/main/.github/workflows/azure-dev.yml)
- [Deploy with Azure Pipelines](https://github.com/Azure-Samples/azd-starter-bicep/blob/main/.azdo/pipelines/azure-dev.yml)
- [Deploy with GitHub Actions](https://github.com/Azure-Samples/azd-starter-bicep/blob/main/.github/workflows/azure-dev.yml)
- [Deploy with Azure Pipelines](https://github.com/Azure-Samples/azd-starter-bicep/blob/main/.azdo/pipelines/azure-dev.yml)
2. Run `azd pipeline config` to configure the deployment pipeline to connect securely to Azure.

## What was added
Expand All @@ -43,10 +43,10 @@ To describe the infrastructure and application, `azure.yaml` along with Infrastr
Each bicep file declares resources to be provisioned. The resources are provisioned when running `azd up` or `azd provision`.

- [app/ddd-2024.bicep](./infra/app/ddd-2024.bicep) - Azure Container Apps resources to host the 'ddd-2024' service.
- [shared/keyvault.bicep](./infra/shared/keyvault.bicep) - Azure KeyVault to store secrets.
- [shared/monitoring.bicep](./infra/shared/monitoring.bicep) - Azure Log Analytics workspace and Application Insights to log and store instrumentation logs.
- [shared/registry.bicep](./infra/shared/registry.bicep) - Azure Container Registry to store docker images.
- [app/dddperth.bicep](./infra/app/dddperth.bicep) - Azure Container Apps resources to host the 'dddperth' service.
- [shared/keyvault.bicep](./infra/shared/keyvault.bicep) - Azure KeyVault to store secrets.
- [shared/monitoring.bicep](./infra/shared/monitoring.bicep) - Azure Log Analytics workspace and Application Insights to log and store instrumentation logs.
- [shared/registry.bicep](./infra/shared/registry.bicep) - Azure Container Registry to store docker images.

More information about [Bicep](https://aka.ms/bicep) language.

Expand All @@ -59,7 +59,7 @@ If your project does not contain a Dockerfile, we will use [Buildpacks](https://
To produce and run the docker image locally:

1. Run `azd package` to build the image.
2. Copy the *Image Tag* shown.
2. Copy the _Image Tag_ shown.
3. Run `docker run -it <Image Tag>` to run the image locally.

#### Exposed port
Expand All @@ -71,7 +71,7 @@ Oryx will automatically set `PORT` to a default value of `80` (port `8080` for J

## Billing

Visit the *Cost Management + Billing* page in Azure Portal to track current spend. For more information about how you're billed, and how you can monitor the costs incurred in your Azure subscriptions, visit [billing overview](https://learn.microsoft.com/azure/developer/intro/azure-developer-billing).
Visit the _Cost Management + Billing_ page in Azure Portal to track current spend. For more information about how you're billed, and how you can monitor the costs incurred in your Azure subscriptions, visit [billing overview](https://learn.microsoft.com/azure/developer/intro/azure-developer-billing).

## Troubleshooting

Expand All @@ -84,9 +84,9 @@ A: Your service may have failed to start, or it may be missing some configuratio
3. Click on the failing revision under "Revisions with Issues".
4. Review "Status details" for more information about the type of failure.
5. Observe the log outputs from Console log stream and System log stream to identify any errors.
6. If logs are written to disk, use *Console* in the navigation to connect to a shell within the running container.
6. If logs are written to disk, use _Console_ in the navigation to connect to a shell within the running container.

For more troubleshooting information, visit [Container Apps troubleshooting](https://learn.microsoft.com/azure/container-apps/troubleshooting).
For more troubleshooting information, visit [Container Apps troubleshooting](https://learn.microsoft.com/azure/container-apps/troubleshooting).

### Additional information

Expand Down

0 comments on commit 010f31d

Please sign in to comment.