Skip to content

Commit 34f6aea

Browse files
authored
Merge pull request #1 from Azure-Samples/hallvictoria/add-initial-samples
Add deployable samples
2 parents 7cb4c72 + 1760421 commit 34f6aea

70 files changed

Lines changed: 3042 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.scaffold/host.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "2.0",
3+
"logging": {
4+
"logLevel": {
5+
"Microsoft.Azure.Functions.Extensions.Connector": "Information"
6+
},
7+
"applicationInsights": {
8+
"samplingSettings": {
9+
"isEnabled": true,
10+
"excludedTypes": "Request"
11+
}
12+
}
13+
},
14+
"extensionBundle": {
15+
"id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
16+
"version": "[4.42.*, 5.0.0)"
17+
}
18+
}

.scaffold/infra/main.bicep

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
// ----------------------------------------------------------------------------
5+
// Subscription-scoped entrypoint used by `azd up`.
6+
// Creates the resource group and delegates to resources.bicep.
7+
// ----------------------------------------------------------------------------
8+
9+
targetScope = 'subscription'
10+
11+
@minLength(1)
12+
@maxLength(64)
13+
@description('Name of the azd environment. Used to derive resource names.')
14+
param environmentName string
15+
16+
@minLength(1)
17+
@description('Primary location for all resources.')
18+
param location string
19+
20+
@description('Connector runtime URL (e.g. https://<connection-name>-<gateway>.azureconnectors.com). Optional at provisioning time; configure later as app setting.')
21+
param connectorRuntimeUrl string = ''
22+
23+
@description('Connector OAuth access token. Optional at provisioning time; configure later as app setting or rotate via Key Vault.')
24+
@secure()
25+
param connectorToken string = ''
26+
27+
var tags = {
28+
'azd-env-name': environmentName
29+
}
30+
31+
resource resourceGroup 'Microsoft.Resources/resourceGroups@2024-03-01' = {
32+
name: 'rg-${environmentName}'
33+
location: location
34+
tags: tags
35+
}
36+
37+
module resources 'resources.bicep' = {
38+
scope: resourceGroup
39+
name: 'resources'
40+
params: {
41+
location: location
42+
environmentName: environmentName
43+
tags: tags
44+
connectorRuntimeUrl: connectorRuntimeUrl
45+
connectorToken: connectorToken
46+
}
47+
}
48+
49+
output AZURE_LOCATION string = location
50+
output AZURE_RESOURCE_GROUP string = resourceGroup.name
51+
output FUNCTION_APP_NAME string = resources.outputs.functionAppName
52+
output FUNCTION_APP_HOSTNAME string = resources.outputs.functionAppHostname
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"environmentName": {
6+
"value": "${AZURE_ENV_NAME}"
7+
},
8+
"location": {
9+
"value": "${AZURE_LOCATION}"
10+
},
11+
"connectorRuntimeUrl": {
12+
"value": "${CONNECTOR_RUNTIME_URL=}"
13+
},
14+
"connectorToken": {
15+
"value": "${CONNECTOR_TOKEN=}"
16+
}
17+
}
18+
}

.scaffold/infra/resources.bicep

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
// ----------------------------------------------------------------------------
5+
// Resource-group-scoped resources: Storage, App Insights, Function App.
6+
// ----------------------------------------------------------------------------
7+
8+
@minLength(1)
9+
param environmentName string
10+
11+
@minLength(1)
12+
param location string
13+
14+
param tags object = {}
15+
16+
param connectorRuntimeUrl string = ''
17+
18+
@secure()
19+
param connectorToken string = ''
20+
21+
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
22+
var storageAccountName = take('st${replace(resourceToken, '-', '')}', 24)
23+
var planName = 'plan-${environmentName}-${resourceToken}'
24+
var functionAppName = 'func-${environmentName}-${resourceToken}'
25+
var appInsightsName = 'appi-${environmentName}-${resourceToken}'
26+
var logAnalyticsName = 'log-${environmentName}-${resourceToken}'
27+
28+
resource storage 'Microsoft.Storage/storageAccounts@2023-05-01' = {
29+
name: storageAccountName
30+
location: location
31+
kind: 'StorageV2'
32+
sku: {
33+
name: 'Standard_LRS'
34+
}
35+
properties: {
36+
minimumTlsVersion: 'TLS1_2'
37+
allowBlobPublicAccess: false
38+
supportsHttpsTrafficOnly: true
39+
}
40+
tags: tags
41+
}
42+
43+
resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
44+
name: logAnalyticsName
45+
location: location
46+
properties: {
47+
sku: {
48+
name: 'PerGB2018'
49+
}
50+
retentionInDays: 30
51+
}
52+
tags: tags
53+
}
54+
55+
resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
56+
name: appInsightsName
57+
location: location
58+
kind: 'web'
59+
properties: {
60+
Application_Type: 'web'
61+
WorkspaceResourceId: logAnalytics.id
62+
}
63+
tags: tags
64+
}
65+
66+
resource appPlan 'Microsoft.Web/serverfarms@2023-12-01' = {
67+
name: planName
68+
location: location
69+
kind: 'linux'
70+
sku: {
71+
name: 'Y1'
72+
tier: 'Dynamic'
73+
}
74+
properties: {
75+
reserved: true
76+
}
77+
tags: tags
78+
}
79+
80+
resource functionApp 'Microsoft.Web/sites@2023-12-01' = {
81+
name: functionAppName
82+
location: location
83+
kind: 'functionapp,linux'
84+
identity: {
85+
type: 'SystemAssigned'
86+
}
87+
properties: {
88+
serverFarmId: appPlan.id
89+
httpsOnly: true
90+
siteConfig: {
91+
linuxFxVersion: 'Node|20'
92+
ftpsState: 'FtpsOnly'
93+
minTlsVersion: '1.2'
94+
appSettings: [
95+
{
96+
name: 'AzureWebJobsStorage'
97+
value: 'DefaultEndpointsProtocol=https;AccountName=${storage.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storage.listKeys().keys[0].value}'
98+
}
99+
{
100+
name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
101+
value: 'DefaultEndpointsProtocol=https;AccountName=${storage.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storage.listKeys().keys[0].value}'
102+
}
103+
{
104+
name: 'WEBSITE_CONTENTSHARE'
105+
value: toLower(functionAppName)
106+
}
107+
{
108+
name: 'FUNCTIONS_EXTENSION_VERSION'
109+
value: '~4'
110+
}
111+
{
112+
name: 'FUNCTIONS_WORKER_RUNTIME'
113+
value: 'node'
114+
}
115+
{
116+
name: 'WEBSITE_NODE_DEFAULT_VERSION'
117+
value: '~20'
118+
}
119+
{
120+
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
121+
value: appInsights.properties.ConnectionString
122+
}
123+
{
124+
name: 'ConnectorRuntimeUrl'
125+
value: connectorRuntimeUrl
126+
}
127+
{
128+
name: 'ConnectorToken'
129+
value: connectorToken
130+
}
131+
]
132+
}
133+
}
134+
tags: union(tags, {
135+
'azd-service-name': 'api'
136+
})
137+
}
138+
139+
output functionAppName string = functionApp.name
140+
output functionAppHostname string = functionApp.properties.defaultHostName

.scaffold/src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
import { app } from '@azure/functions';
5+
6+
app.setup({
7+
enableHttpStream: true,
8+
});

.scaffold/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"module": "es2022",
4+
"moduleResolution": "bundler",
5+
"target": "es2022",
6+
"strict": true,
7+
"esModuleInterop": true,
8+
"outDir": "dist",
9+
"sourceMap": true,
10+
"rootDir": "src"
11+
},
12+
"include": ["src/**/*"]
13+
}

0 commit comments

Comments
 (0)