Skip to content

Commit

Permalink
Updated with working versions
Browse files Browse the repository at this point in the history
  • Loading branch information
cwiederspan committed Feb 1, 2024
1 parent 10d5f6a commit 5d94854
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 209 deletions.
22 changes: 14 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,34 @@

"features": {
"ghcr.io/devcontainers/features/azure-cli:1": {
"version": "latest",
"installBicep": true
"installBicep": true,
"version": "latest"
},
"ghcr.io/azure/azure-dev/azd:0": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/common-utils:2": {}
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"configureZshAsDefaultShell": true,
"installOhMyZsh": true,
"installOhMyZshConfig": true,
"upgradePackages": true
},
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {}
},

"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh"
//"terminal.integrated.defaultProfile.linux": "zsh"
},
"extensions": [
"ms-dotnettools.csdevkit",
"humao.rest-client"
"humao.rest-client",
"GitHub.vscode-github-actions"
]
}
},

"postCreateCommand": "git config devcontainers-theme.show-dirty 1"
}

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
Expand Down
32 changes: 6 additions & 26 deletions azure.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json

# This is an example starter azure.yaml file containing several example services in comments below.
# Make changes as needed to describe your application setup.
# To learn more about the azure.yaml file, visit https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/azd-schema

# Name of the application.
name: azd-starter
# services:
# ## An example for a python API service.
# ## The service is named 'python-api'.
# ## The language is 'python'.
# ## The source code is located in the project (azure.yaml) directory.
# ## The service will be hosted on Azure App Service.
# python-api:
# language: python
# project: ./
# host: appservice
# ## An example for a NodeJS API, located in src/api.
# nodejs-api:
# language: js
# project: ./src/api
# host: appservice
# ## An example for a React front-end app.
# ## The src/react-app/build folder is where the app is built to after `npm run build`.
# react-web:
# language: js
# project: ./src/react-app
# host: appservice
# dist: build
name: my-application
services:
api:
language: csharp
project: ./src/api
host: appservice
136 changes: 0 additions & 136 deletions infra/abbreviations.json

This file was deleted.

34 changes: 34 additions & 0 deletions infra/app/api.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
param name string
param location string = resourceGroup().location
param tags object = {}

param allowedOrigins array = []
param appCommandLine string = ''
param applicationInsightsName string = ''
param appServicePlanId string
@secure()
param appSettings object = {}
param keyVaultName string
param serviceName string = 'api'

module api '../core/host/appservice.bicep' = {
name: '${name}-app-module'
params: {
name: name
location: location
tags: union(tags, { 'azd-service-name': serviceName })
allowedOrigins: allowedOrigins
appCommandLine: appCommandLine
applicationInsightsName: applicationInsightsName
appServicePlanId: appServicePlanId
appSettings: appSettings
keyVaultName: keyVaultName
runtimeName: 'dotnetcore'
runtimeVersion: '8.0'
scmDoBuildDuringDeployment: false
}
}

output SERVICE_API_IDENTITY_PRINCIPAL_ID string = api.outputs.identityPrincipalId
output SERVICE_API_NAME string = api.outputs.name
output SERVICE_API_URI string = api.outputs.uri
95 changes: 70 additions & 25 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,98 @@ targetScope = 'subscription'

@minLength(1)
@maxLength(64)
@description('Name of the the environment which is used to generate a short unique hash used in all resources.')
@description('Name of the the environment which is used to generate all other names.')
param environmentName string

@minLength(1)
@description('Primary location for all resources')
param location string

// Optional parameters to override the default azd resource naming conventions.
// Add the following to main.parameters.json to provide values:
// "resourceGroupName": {
// "value": "myGroupName"
// }
param resourceGroupName string = ''

var abbrs = loadJsonContent('./abbreviations.json')
@description('Id of the user or app to assign application roles')
param principalId string = ''

// tags that should be applied to all resources.
var tags = {
// Tag all resources with the environment name.
'azd-env-name': environmentName
}

// Generate a unique token to be used in naming resources.
// Remove linter suppression after using.
#disable-next-line no-unused-vars
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))

// Name of the service defined in azure.yaml
// A tag named azd-service-name with this value should be applied to the service host resource, such as:
// Microsoft.Web/sites for appservice, function
// Example usage:
// tags: union(tags, { 'azd-service-name': apiServiceName })
#disable-next-line no-unused-vars
var apiServiceName = 'python-api'

// Organize resources in a resource group
resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: !empty(resourceGroupName) ? resourceGroupName : '${abbrs.resourcesResourceGroups}${environmentName}'
name: environmentName
location: location
tags: tags
}

// Add resources to be provisioned below.
// A full example that leverages azd bicep modules can be seen in the todo-python-mongo template:
// https://github.com/Azure-Samples/todo-python-mongo/tree/main/infra

// Monitor application with Azure Monitor
module monitoring './core/monitor/monitoring.bicep' = {
name: 'monitoring'
scope: rg
params: {
location: location
tags: tags
logAnalyticsName: '${environmentName}-law'
applicationInsightsName: '${environmentName}-apm'
applicationInsightsDashboardName: '${environmentName}-dash'
}
}

// Store secrets in a keyvault
module keyVault './core/security/keyvault.bicep' = {
name: 'keyvault'
scope: rg
params: {
name: '${environmentName}-kv'
location: location
tags: tags
principalId: principalId
}
}

// Give the API access to KeyVault
module apiKeyVaultAccess './core/security/keyvault-access.bicep' = {
name: 'api-keyvault-access'
scope: rg
params: {
keyVaultName: keyVault.outputs.name
principalId: api.outputs.SERVICE_API_IDENTITY_PRINCIPAL_ID
}
}

// Create an App Service Plan to group applications under the same payment plan and SKU
module appServicePlan './core/host/appserviceplan.bicep' = {
name: 'appserviceplan'
scope: rg
params: {
name: '${environmentName}-plan'
location: location
tags: tags
sku: {
name: 'B1'
}
}
}

// The application backend
module api './app/api.bicep' = {
name: 'api'
scope: rg
params: {
name: '${environmentName}-api'
location: location
tags: tags
applicationInsightsName: monitoring.outputs.applicationInsightsName
appServicePlanId: appServicePlan.outputs.id
keyVaultName: keyVault.outputs.name
//allowedOrigins: [ web.outputs.SERVICE_WEB_URI ]
appSettings: {
//API_ALLOW_ORIGINS: web.outputs.SERVICE_WEB_URI
WELCOME_MESSAGE: 'Hello, World!'
}
}
}

// Add outputs from the deployment here, if needed.
//
Expand Down
Loading

0 comments on commit 5d94854

Please sign in to comment.