Skip to content

updated with redis #17

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

Merged
merged 1 commit into from
Oct 30, 2024
Merged
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
91 changes: 52 additions & 39 deletions src/InfrastructureAsCode/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,56 @@ var webAppName = '${uniqueString(resourceGroup().id)}-${environment}'
var appServicePlanName = '${uniqueString(resourceGroup().id)}-mpnp-asp'
var logAnalyticsName = '${uniqueString(resourceGroup().id)}-mpnp-la'
var appInsightsName = '${uniqueString(resourceGroup().id)}-mpnp-ai'
var sku = 'S1'
var sku = 'P0V3'
var registryName = '${uniqueString(resourceGroup().id)}mpnpreg'
var registrySku = 'Standard'
var imageName = 'techexcel/dotnetcoreapp'
var startupCommand = ''
var redisCacheName = '${uniqueString(resourceGroup().id)}-mpnp-redis'
var redisCacheSku = 'Basic'

// Create Log Analytics Workspace
resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2021-06-01' = {
resource redisCache 'Microsoft.Cache/Redis@2023-08-01' = {
name: redisCacheName
location: location
properties: {
sku: {
name: redisCacheSku
family: 'C'
capacity: 0
}
enableNonSslPort: false
minimumTlsVersion: '1.2'
redisConfiguration: {
'maxmemory-policy': 'volatile-lru'
}
}
}

resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2021-12-01-preview' = {
name: logAnalyticsName
location: location
properties: {
sku: {
name: 'PerGB2018'
}
retentionInDays: 30
retentionInDays: 90
workspaceCapping: {
dailyQuotaGb: 1
}
}
}

// Create Application Insights
resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
resource appInsights 'Microsoft.Insights/components@2020-02-02-preview' = {
name: appInsightsName
location: location
kind: 'web'
properties: {
Application_Type: 'web'
WorkspaceResourceId: logAnalytics.id
WorkspaceResourceId: logAnalyticsWorkspace.id
}
}

// Create Azure Container Registry
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2021-06-01-preview' = {
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2020-11-01-preview' = {
name: registryName
location: location
sku: {
Expand All @@ -49,62 +68,56 @@ resource containerRegistry 'Microsoft.ContainerRegistry/registries@2021-06-01-pr
}
}

// Create App Service Plan
resource appServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = {
resource appServicePlan 'Microsoft.Web/serverFarms@2022-09-01' = {
name: appServicePlanName
location: location
kind: 'linux'
properties: {
reserved: true
}
sku: {
name: sku
tier: 'Standard'
}
properties: {
reserved: true // This property is required for Linux
}
}

// Create Web App
resource webApp 'Microsoft.Web/sites@2021-02-01' = {
resource appServiceApp 'Microsoft.Web/sites@2020-12-01' = {
name: webAppName
location: location
properties: {
serverFarmId: appServicePlan.id
httpsOnly: true
clientAffinityEnabled: false
siteConfig: {
linuxFxVersion: 'DOCKER|${imageName}'
linuxFxVersion: 'DOCKER|${containerRegistry.name}.azurecr.io/${uniqueString(resourceGroup().id)}/${imageName}'
http20Enabled: true
minTlsVersion: '1.2'
appCommandLine: startupCommand
appSettings: [
{
name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE'
value: 'false'
}
{
name: 'DOCKER_REGISTRY_SERVER_URL'
value: 'https://${registryName}.azurecr.io'
value: 'https://${containerRegistry.name}.azurecr.io'
}
{
name: 'DOCKER_REGISTRY_SERVER_USERNAME'
value: containerRegistry.properties.adminUserEnabled ? listCredentials(containerRegistry.id, '2021-06-01-preview').username : ''
value: containerRegistry.name
}
{
name: 'DOCKER_REGISTRY_SERVER_PASSWORD'
value: containerRegistry.properties.adminUserEnabled ? listCredentials(containerRegistry.id, '2021-06-01-preview').passwords[0].value : ''
value: containerRegistry.listCredentials().passwords[0].value
}
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: appInsights.properties.InstrumentationKey
}
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: appInsights.properties.ConnectionString
}
{
name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE'
value: 'false'
}
{
name: 'WEBSITES_PORT'
value: '80' // Default port for your application
}
]
]
}
}
}
}

// Outputs
output appServiceName string = webApp.name
output appServiceUrl string = 'https://${webAppName}.azurewebsites.net'
output containerRegistryName string = containerRegistry.name
output application_name string = appServiceApp.name
output application_url string = appServiceApp.properties.hostNames[0]
output container_registry_name string = containerRegistry.name