Skip to content
Open

Task2 #239

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
Binary file added Results/AppSpainCentral.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Results/PublicApi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Results/Scale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Results/TM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Results/WebEastUs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

name: eShopOnWeb
services:
web:
web-primary:
project: ./src/Web
language: csharp
host: appservice
web-secondary:
project: ./src/Web
language: csharp
host: appservice
public-api:
project: ./src/PublicApi
language: csharp
host: appservice
47 changes: 31 additions & 16 deletions infra/core/host/appservice.bicep
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
param name string
param location string = resourceGroup().location
param tags object = {}
param enableSlot bool = false
param slotName string = ''

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

// Runtime Properties
@allowed([
Expand Down Expand Up @@ -34,6 +33,7 @@ param scmDoBuildDuringDeployment bool = false
param use32BitWorkerProcess bool = false
param ftpsState string = 'FtpsOnly'
param healthCheckPath string = ''
param aspNetCoreEnvironment string = 'Development'

resource appService 'Microsoft.Web/sites@2022-03-01' = {
name: name
Expand Down Expand Up @@ -61,17 +61,15 @@ resource appService 'Microsoft.Web/sites@2022-03-01' = {
httpsOnly: true
}

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

resource configAppSettings 'config' = {
name: 'appsettings'
properties: union(appSettings,
{
properties: union(appSettings, {
SCM_DO_BUILD_DURING_DEPLOYMENT: string(scmDoBuildDuringDeployment)
ENABLE_ORYX_BUILD: string(enableOryxBuild)
},
!empty(applicationInsightsName) ? { APPLICATIONINSIGHTS_CONNECTION_STRING: applicationInsights.properties.ConnectionString } : {},
!empty(keyVaultName) ? { AZURE_KEY_VAULT_ENDPOINT: keyVault.properties.vaultUri } : {})
ASPNETCORE_ENVIRONMENT: aspNetCoreEnvironment
})
}

resource configLogs 'config' = {
Expand All @@ -88,14 +86,31 @@ resource appService 'Microsoft.Web/sites@2022-03-01' = {
}
}

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
// Deployment slot (created only when enabled)
resource appSlot 'Microsoft.Web/sites/slots@2022-03-01' = if (enableSlot) {
parent: appService
name: slotName
location: location
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
}
clientAffinityEnabled: clientAffinityEnabled
httpsOnly: true
}
}

output identityPrincipalId string = managedIdentity ? appService.identity.principalId : ''
output id string = appService.id
output name string = appService.name
output hostName string = appService.properties.defaultHostName
output uri string = 'https://${appService.properties.defaultHostName}'
70 changes: 70 additions & 0 deletions infra/core/host/scaleoncpu.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
param name string
param targetResourceUri string
param minimum string = '1'
param maximum string = '2'
param default string = '1'

param location string = resourceGroup().location
param tags object = {}

resource scaleOnCpu 'Microsoft.Insights/autoscaleSettings@2015-04-01' = {
name: name
location: location
tags: tags
properties: {
enabled: true
targetResourceUri: targetResourceUri
targetResourceLocation: location
notifications: []
profiles: [
{
name: 'Scale on CPU'
capacity: {
minimum: minimum
maximum: maximum
default: default
}
rules: [
{
metricTrigger: {
metricName: 'CpuPercentage'
metricNamespace: 'microsoft.web/serverfarms'
metricResourceUri: targetResourceUri
operator: 'GreaterThan'
statistic: 'Average'
threshold: 70
timeAggregation: 'Average'
timeGrain: 'PT1M'
timeWindow: 'PT10M'
}
scaleAction: {
cooldown: 'PT5M'
direction: 'Increase'
type: 'ChangeCount'
value: '1'
}
}
{
metricTrigger: {
metricName: 'CpuPercentage'
metricNamespace: 'microsoft.web/serverfarms'
metricResourceUri: targetResourceUri
operator: 'LessThan'
statistic: 'Average'
threshold: 50
timeAggregation: 'Average'
timeGrain: 'PT1M'
timeWindow: 'PT10M'
}
scaleAction: {
cooldown: 'PT5M'
direction: 'Decrease'
type: 'ChangeCount'
value: '1'
}
}
]
}
]
}
}
55 changes: 55 additions & 0 deletions infra/core/network/trafficManager.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
targetScope = 'resourceGroup'

@minLength(1)
param profileName string

@minLength(1)
param relativeName string

param tags object = {}

@minLength(1)
param primaryId string

@minLength(1)
param secondaryId string

resource profile 'Microsoft.Network/trafficManagerProfiles@2018-08-01' = {
name: profileName
location: 'global'
tags: tags
properties: {
profileStatus: 'Enabled'
trafficRoutingMethod: 'Performance'
dnsConfig: {
relativeName: relativeName
ttl: 30
}
monitorConfig: {
protocol: 'HTTP'
port: 80
path: '/'
}
endpoints: [
{
name: 'primary-endpoint'
type: 'Microsoft.Network/trafficManagerProfiles/azureEndpoints'
properties: {
targetResourceId: primaryId
endpointStatus: 'Enabled'
}
}
{
name: 'secondary-endpoint'
type: 'Microsoft.Network/trafficManagerProfiles/azureEndpoints'
properties: {
targetResourceId: secondaryId
endpointStatus: 'Enabled'
}
}
]
}
}

output relativeName string = profile.properties.dnsConfig.relativeName
output profileName string = profile.name
Loading