-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
266 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
param ( | ||
[Parameter()] | ||
[ValidateSet('none', 'json')] | ||
[string] | ||
$verbosity = 'none' | ||
) | ||
|
||
$user = az account show --query user.name | ||
if($null -eq $user) { | ||
az login --output $verbosity | ||
$user = az account show --query user.name | ||
} | ||
|
||
write-host "logged in as $user" -ForegroundColor Green | ||
write-host "deploying resources..." -ForegroundColor Yellow | ||
|
||
$location='eastus' | ||
$serviceName='evenire' | ||
$env='dev' | ||
|
||
az deployment sub create --location=$location ` | ||
--template-file ./src/infra/main.bicep ` | ||
--parameters service_name=$serviceName location=$location env=$env | ||
|
||
# the http20ProxyFlag is not yet supported in the bicep template, so we need to set it manually | ||
$subscriptionId = $(az account show --query id --output tsv) | ||
$resourceGroupName = "rg-$serviceName" | ||
$webAppName = "web-$serviceName-$env" | ||
$uri = "https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.Web/sites/$webAppName/config/web?api-version=2022-03-01" | ||
az rest ` | ||
--method PUT ` | ||
--uri $uri ` | ||
--body '{\"properties\":{\"http20ProxyFlag\":1}}' | ||
|
||
write-host "deployment complete!" -ForegroundColor Green |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
param location string | ||
param service_name string | ||
|
||
var container_registry_name = 'cr${service_name}' | ||
|
||
resource container_registry_resource 'Microsoft.ContainerRegistry/registries@2023-08-01-preview' = { | ||
name: container_registry_name | ||
location: location | ||
sku: { | ||
name: 'Basic' | ||
} | ||
properties: { | ||
adminUserEnabled: true | ||
} | ||
} | ||
|
||
output container_registry_name string = container_registry_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
param location string | ||
param service_name string | ||
|
||
var logs_name = 'logs-${service_name}' | ||
|
||
resource logs_resource 'microsoft.insights/components@2020-02-02' = { | ||
name: logs_name | ||
location: location | ||
kind: 'web' | ||
properties: { | ||
Application_Type: 'web' | ||
Flow_Type: 'Redfield' | ||
Request_Source: 'IbizaAIExtension' | ||
RetentionInDays: 30 | ||
IngestionMode: 'ApplicationInsights' | ||
publicNetworkAccessForIngestion: 'Enabled' | ||
publicNetworkAccessForQuery: 'Enabled' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
targetScope = 'subscription' | ||
|
||
param service_name string = 'evenire' | ||
param location string = 'eastus' | ||
param plan_sku string = 'F1' | ||
|
||
@allowed([ | ||
'dev' | ||
'prod' | ||
]) | ||
param env string = 'dev' | ||
|
||
var resourceGroupName = 'rg-${service_name}' | ||
|
||
resource resource_group_resource 'Microsoft.Resources/resourceGroups@2022-09-01' = { | ||
name: resourceGroupName | ||
location: location | ||
} | ||
|
||
module container_registry './container_registry.bicep' = { | ||
name: 'acr' | ||
scope: resource_group_resource | ||
params: { | ||
location: location | ||
service_name: service_name | ||
} | ||
} | ||
|
||
module logs './logs.bicep' = { | ||
name: 'logs' | ||
scope: resource_group_resource | ||
params: { | ||
location: location | ||
service_name: service_name | ||
} | ||
} | ||
|
||
module webapp './webapp.bicep' = { | ||
name: 'app' | ||
dependsOn: [ | ||
container_registry | ||
logs | ||
] | ||
scope: resource_group_resource | ||
params: { | ||
location: location | ||
service_name: service_name | ||
plan_sku: plan_sku | ||
container_registry_name: container_registry.outputs.container_registry_name | ||
env: env | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
param location string | ||
param service_name string | ||
param plan_sku string | ||
param container_registry_name string | ||
param env string | ||
|
||
var web_app_name = 'web-${service_name}-${env}' | ||
var web_plan_name = 'plan-${service_name}-${env}' | ||
var always_on = plan_sku != 'F1' | ||
var image = '${container_registry_name}.azurecr.io/eveniredb:latest' | ||
|
||
var appEnv = env == 'dev' ? 'Development' : 'Production' | ||
|
||
resource acr 'Microsoft.ContainerRegistry/registries@2023-08-01-preview' existing = { | ||
name: container_registry_name | ||
} | ||
|
||
resource web_plan_resource 'Microsoft.Web/serverfarms@2022-09-01' = { | ||
name: web_plan_name | ||
location: location | ||
sku: { | ||
name: plan_sku | ||
size: plan_sku | ||
} | ||
kind: 'linux' | ||
properties: { | ||
targetWorkerSizeId: 0 | ||
targetWorkerCount: 1 | ||
reserved: true | ||
zoneRedundant: false | ||
} | ||
} | ||
|
||
resource web_app_resource 'Microsoft.Web/sites@2022-09-01' = { | ||
name: web_app_name | ||
location: location | ||
kind: 'app,linux,container' | ||
dependsOn:[ | ||
acr | ||
] | ||
properties: { | ||
serverFarmId: web_plan_resource.id | ||
enabled: true | ||
httpsOnly: true | ||
siteConfig: { | ||
numberOfWorkers: 1 | ||
alwaysOn: always_on | ||
http20Enabled: true | ||
http20ProxyFlag: 1 // this is apparently not yet supported, so have to set it manually using CLI after deployment | ||
linuxFxVersion: 'DOCKER|${image}' | ||
appSettings:[ | ||
{ | ||
name: 'DOCKER_ENABLE_CI' | ||
value: 'true' | ||
} | ||
{ | ||
name: 'DOCKER_CUSTOM_IMAGE_NAME' | ||
value: image | ||
} | ||
{ | ||
name: 'DOCKER_REGISTRY_SERVER_URL' | ||
value: acr.properties.loginServer | ||
} | ||
{ | ||
name: 'DOCKER_REGISTRY_SERVER_USERNAME' | ||
value: acr.name | ||
} | ||
{ | ||
name: 'DOCKER_REGISTRY_SERVER_PASSWORD' | ||
value: acr.listCredentials().passwords[0].value | ||
} | ||
{ | ||
name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE' | ||
value: 'false' | ||
} | ||
{ | ||
name: 'ASPNETCORE_ENVIRONMENT' | ||
value: appEnv | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
var publishingCredentialsId = resourceId('Microsoft.Web/sites/config', web_app_name, 'publishingCredentials') | ||
var publishingcreds = list(publishingCredentialsId, '2022-03-01') | ||
var scmUri = publishingcreds.properties.scmUri | ||
var hook_name = '${service_name}hook' | ||
|
||
resource hook 'Microsoft.ContainerRegistry/registries/webhooks@2023-08-01-preview' = { | ||
parent: acr | ||
dependsOn:[ web_app_resource ] | ||
location: location | ||
name: hook_name | ||
properties: { | ||
serviceUri: '${scmUri}/docker/hook' | ||
status: 'enabled' | ||
actions: [ | ||
'push' | ||
] | ||
} | ||
} |