Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add func #209

Merged
merged 6 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"GitHub.vscode-github-actions",
"esbenp.prettier-vscode",
"ipedrazas.kubernetes-snippets",
"ms-azuretools.azure-dev",
"ms-azuretools.vscode-azurecontainerapps",
"ms-azuretools.vscode-azurefunctions",
"ms-azuretools.vscode-azurestorage",
"ms-azuretools.vscode-azurecontainerapps",
"ms-azuretools.vscode-docker",
"ms-dotnettools.blazorwasm-companion",
"ms-dotnettools.csdevkit",
"ms-dotnettools.csharp",
"ms-dotnettools.vscode-dotnet-runtime",
"ms-dotnettools.blazorwasm-companion",
"ms-kubernetes-tools.vscode-aks-tools",
"ms-kubernetes-tools.aks-devx-tools",
"ms-kubernetes-tools.vscode-aks-tools",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"ipedrazas.kubernetes-snippets",
"redhat.vscode-yaml",
"GitHub.vscode-github-actions",
"esbenp.prettier-vscode"
"redhat.vscode-yaml"
]
}
},
Expand Down
37 changes: 19 additions & 18 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{
"recommendations": [
"ms-azuretools.vscode-azurefunctions",
"ms-dotnettools.csharp",
"ms-azuretools.vscode-docker",
"ms-azuretools.vscode-azurestorage",
"ms-azuretools.vscode-azurecontainerapps",
"ms-dotnettools.csdevkit",
"ms-dotnettools.vscode-dotnet-runtime",
"ms-dotnettools.blazorwasm-companion",
"ms-kubernetes-tools.vscode-aks-tools",
"ms-kubernetes-tools.aks-devx-tools",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"ipedrazas.kubernetes-snippets",
"redhat.vscode-yaml",
"GitHub.vscode-github-actions",
"esbenp.prettier-vscode"
]
}
"recommendations": [
"GitHub.vscode-github-actions",
"esbenp.prettier-vscode",
"ipedrazas.kubernetes-snippets",
"ms-azuretools.azure-dev",
"ms-azuretools.vscode-azurecontainerapps",
"ms-azuretools.vscode-azurefunctions",
"ms-azuretools.vscode-azurestorage",
"ms-azuretools.vscode-docker",
"ms-dotnettools.blazorwasm-companion",
"ms-dotnettools.csdevkit",
"ms-dotnettools.csharp",
"ms-dotnettools.vscode-dotnet-runtime",
"ms-kubernetes-tools.aks-devx-tools",
"ms-kubernetes-tools.vscode-aks-tools",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"redhat.vscode-yaml"
]
}
101 changes: 52 additions & 49 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,54 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Frontend: Blazor client",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}//app/backend/bin/Debug/net8.0/ClientApp.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"envFile": "${input:dotEnvFilePath}"
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Frontend: Blazor client",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/app/backend/bin/Debug/net8.0/ClientApp.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
{
"name": "Backend: Minimal API",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/app/backend/bin/Debug/net8.0/MinimalApi.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole",
"envFile": "${input:dotEnvFilePath}"
}
],
"inputs": [
{
"id": "dotEnvFilePath",
"type": "command",
"command": "azure-dev.commands.getDotEnvFilePath"
}
],
"compounds": [
{
"name": "Full Stack",
"configurations": ["Backend: Minimal API", "Frontend: Blazor client"]
}
]
}
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"envFile": "${input:dotEnvFilePath}"
},
{
"name": "Backend: Minimal API",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/app/backend/bin/Debug/net8.0/MinimalApi.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole",
"envFile": "${input:dotEnvFilePath}"
}
],
"inputs": [
{
"id": "dotEnvFilePath",
"type": "command",
"command": "azure-dev.commands.getDotEnvFilePath"
}
],
"compounds": [
{
"name": "Full Stack",
"configurations": [
"Backend: Minimal API",
"Frontend: Blazor client"
]
}
]
}
4 changes: 4 additions & 0 deletions azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ services:
docker:
path: ../Dockerfile
context: ../
function:
project: ./app/functions/EmbedFunctions
host: function
language: dotnet
hooks:
postprovision:
windows:
Expand Down
35 changes: 35 additions & 0 deletions infra/app/function.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
param name string
param location string = resourceGroup().location
param tags object = {}

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

module function '../core/host/functions.bicep' = {
name: '${serviceName}-function'
params: {
name: name
location: location
tags: union(tags, { 'azd-service-name': serviceName })
allowedOrigins: allowedOrigins
alwaysOn: false
appSettings: appSettings
applicationInsightsName: applicationInsightsName
appServicePlanId: appServicePlanId
keyVaultName: keyVaultName
runtimeName: 'dotnet-isolated'
runtimeVersion: '8.0'
storageAccountName: storageAccountName
scmDoBuildDuringDeployment: false
}
}

output SERVICE_FUNCTION_IDENTITY_PRINCIPAL_ID string = function.outputs.identityPrincipalId
output SERVICE_FUNCTION_NAME string = function.outputs.name
output SERVICE_FUNCTION_URI string = function.outputs.uri
17 changes: 17 additions & 0 deletions infra/core/host/appservice-appsettings.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
metadata description = 'Updates app settings for an Azure App Service.'
@description('The name of the app service resource within the current resource group scope')
param name string

@description('The app settings to be applied to the app service')
@secure()
param appSettings object

resource appService 'Microsoft.Web/sites@2022-03-01' existing = {
name: name
}

resource settings 'Microsoft.Web/sites/config@2022-03-01' = {
name: 'appsettings'
parent: appService
properties: appSettings
}
118 changes: 118 additions & 0 deletions infra/core/host/appservice.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
metadata description = 'Creates an Azure App Service in an existing Azure App Service plan.'
param name string
param location string = resourceGroup().location
param tags object = {}

// Reference Properties
param applicationInsightsName string = ''
param appServicePlanId string
param keyVaultName string = ''
param managedIdentity bool = !empty(keyVaultName)

// Runtime Properties
@allowed([
'dotnet', 'dotnetcore', 'dotnet-isolated', 'node', 'python', 'java', 'powershell', 'custom'
])
param runtimeName string
param runtimeNameAndVersion string = '${runtimeName}|${runtimeVersion}'
param runtimeVersion string

// Microsoft.Web/sites Properties
param kind string = 'app,linux'

// Microsoft.Web/sites/config
param allowedOrigins array = []
param alwaysOn bool = true
param appCommandLine string = ''
@secure()
param appSettings object = {}
param clientAffinityEnabled bool = false
param enableOryxBuild bool = contains(kind, 'linux')
param functionAppScaleLimit int = -1
param linuxFxVersion string = runtimeNameAndVersion
param minimumElasticInstanceCount int = -1
param numberOfWorkers int = -1
param scmDoBuildDuringDeployment bool = false
param use32BitWorkerProcess bool = false
param ftpsState string = 'FtpsOnly'
param healthCheckPath string = ''

resource appService 'Microsoft.Web/sites@2022-03-01' = {
name: name
location: location
tags: tags
kind: kind
properties: {
serverFarmId: appServicePlanId
siteConfig: {
linuxFxVersion: linuxFxVersion
alwaysOn: alwaysOn
ftpsState: ftpsState
minTlsVersion: '1.2'
appCommandLine: appCommandLine
numberOfWorkers: numberOfWorkers != -1 ? numberOfWorkers : null
minimumElasticInstanceCount: minimumElasticInstanceCount != -1 ? minimumElasticInstanceCount : null
use32BitWorkerProcess: use32BitWorkerProcess
functionAppScaleLimit: functionAppScaleLimit != -1 ? functionAppScaleLimit : null
healthCheckPath: healthCheckPath
cors: {
allowedOrigins: union([ 'https://portal.azure.com', 'https://ms.portal.azure.com' ], allowedOrigins)
}
}
clientAffinityEnabled: clientAffinityEnabled
httpsOnly: true
}

identity: { type: managedIdentity ? 'SystemAssigned' : 'None' }

resource configLogs 'config' = {
name: 'logs'
properties: {
applicationLogs: { fileSystem: { level: 'Verbose' } }
detailedErrorMessages: { enabled: true }
failedRequestsTracing: { enabled: true }
httpLogs: { fileSystem: { enabled: true, retentionInDays: 1, retentionInMb: 35 } }
}
}

resource basicPublishingCredentialsPoliciesFtp 'basicPublishingCredentialsPolicies' = {
name: 'ftp'
properties: {
allow: false
}
}

resource basicPublishingCredentialsPoliciesScm 'basicPublishingCredentialsPolicies' = {
name: 'scm'
properties: {
allow: false
}
}
}

module config 'appservice-appsettings.bicep' = if (!empty(appSettings)) {
name: '${name}-appSettings'
params: {
name: appService.name
appSettings: union(appSettings,
{
SCM_DO_BUILD_DURING_DEPLOYMENT: string(scmDoBuildDuringDeployment)
ENABLE_ORYX_BUILD: string(enableOryxBuild)
},
runtimeName == 'python' && appCommandLine == '' ? { PYTHON_ENABLE_GUNICORN_MULTIWORKERS: 'true' } : {},
!empty(applicationInsightsName) ? { APPLICATIONINSIGHTS_CONNECTION_STRING: applicationInsights.properties.ConnectionString } : {},
!empty(keyVaultName) ? { AZURE_KEY_VAULT_ENDPOINT: keyVault.properties.vaultUri } : {})
}
}

resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = if (!(empty(keyVaultName))) {
name: keyVaultName
}

resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = if (!empty(applicationInsightsName)) {
name: applicationInsightsName
}

output identityPrincipalId string = managedIdentity ? appService.identity.principalId : ''
output name string = appService.name
output uri string = 'https://${appService.properties.defaultHostName}'
22 changes: 22 additions & 0 deletions infra/core/host/appserviceplan.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
metadata description = 'Creates an Azure App Service plan.'
param name string
param location string = resourceGroup().location
param tags object = {}

param kind string = ''
param reserved bool = true
param sku object

resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
name: name
location: location
tags: tags
sku: sku
kind: kind
properties: {
reserved: reserved
}
}

output id string = appServicePlan.id
output name string = appServicePlan.name
Loading