Skip to content
Open
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
19 changes: 19 additions & 0 deletions playground/AksDemo/AksDemo.AppHost/aks-acr.module.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@description('The location for the resource(s) to be deployed.')
param location string = resourceGroup().location

resource aks_acr 'Microsoft.ContainerRegistry/registries@2025-04-01' = {
name: take('aksacr${uniqueString(resourceGroup().id)}', 50)
location: location
sku: {
name: 'Basic'
}
tags: {
'aspire-resource-name': 'aks-acr'
}
}

output name string = aks_acr.name

output loginServer string = aks_acr.properties.loginServer

output id string = aks_acr.id
129 changes: 129 additions & 0 deletions playground/AksDemo/AksDemo.AppHost/aks.module.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
@description('The location for the resource(s) to be deployed.')
param location string = resourceGroup().location

param subnetId string

param acrName string

param vnet_outputs_name string

resource aks 'Microsoft.ContainerService/managedClusters@2025-09-02-preview' = {
name: take('aks-${uniqueString(resourceGroup().id)}', 63)
tags: {
'aspire-resource-name': 'aks'
}
location: location
properties: {
dnsPrefix: 'aks-dns'
agentPoolProfiles: [
{
name: 'system'
count: 1
vmSize: 'Standard_D2as_v5'
vnetSubnetID: subnetId
osType: 'Linux'
maxCount: 3
minCount: 1
enableAutoScaling: true
mode: 'System'
}
{
name: 'workload'
count: 1
vmSize: 'Standard_D2as_v5'
vnetSubnetID: subnetId
osType: 'Linux'
maxCount: 3
minCount: 1
enableAutoScaling: true
mode: 'User'
}
]
oidcIssuerProfile: {
enabled: true
}
networkProfile: {
networkPlugin: 'azure'
}
securityProfile: {
workloadIdentity: {
enabled: true
}
}
ingressProfile: {
gatewayAPI: {
installation: 'Standard'
}
applicationLoadBalancer: {
enabled: true
}
}
}
sku: {
name: 'Base'
tier: 'Free'
}
identity: {
type: 'SystemAssigned'
}
}

resource acr 'Microsoft.ContainerRegistry/registries@2025-04-01' existing = {
name: acrName
}

resource acrPullRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(acr.id, aks.id, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d'))
properties: {
principalId: aks.properties.identityProfile.kubeletidentity.objectId
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')
principalType: 'ServicePrincipal'
}
scope: acr
}

resource vnet 'Microsoft.Network/virtualNetworks@2025-05-01' existing = {
name: vnet_outputs_name
}

resource vnet_alb_public_existing 'Microsoft.Network/virtualNetworks/subnets@2025-05-01' existing = {
name: 'alb-public'
parent: vnet
}

resource albSubnetJoin_public 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(vnet_alb_public_existing.id, aks.id, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '4d97b98b-1d4f-4787-a291-c67834d212e7'))
properties: {
principalId: aks.properties.ingressProfile.applicationLoadBalancer.identity.objectId
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '4d97b98b-1d4f-4787-a291-c67834d212e7')
principalType: 'ServicePrincipal'
}
scope: vnet_alb_public_existing
}

resource vnet_alb_admin_existing 'Microsoft.Network/virtualNetworks/subnets@2025-05-01' existing = {
name: 'alb-admin'
parent: vnet
}

resource albSubnetJoin_admin 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(vnet_alb_admin_existing.id, aks.id, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '4d97b98b-1d4f-4787-a291-c67834d212e7'))
properties: {
principalId: aks.properties.ingressProfile.applicationLoadBalancer.identity.objectId
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '4d97b98b-1d4f-4787-a291-c67834d212e7')
principalType: 'ServicePrincipal'
}
scope: vnet_alb_admin_existing
}

output id string = aks.id

output name string = aks.name

output clusterFqdn string = aks.properties.fqdn

output oidcIssuerUrl string = aks.properties.oidcIssuerProfile.issuerURL

output kubeletIdentityObjectId string = aks.properties.identityProfile.kubeletidentity.objectId

output nodeResourceGroup string = aks.properties.nodeResourceGroup
73 changes: 73 additions & 0 deletions playground/AksDemo/AksDemo.AppHost/vnet.module.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
@description('The location for the resource(s) to be deployed.')
param location string = resourceGroup().location

resource vnet 'Microsoft.Network/virtualNetworks@2025-05-01' = {
name: take('vnet-${uniqueString(resourceGroup().id)}', 64)
properties: {
addressSpace: {
addressPrefixes: [
'10.100.0.0/16'
]
}
}
location: location
tags: {
'aspire-resource-name': 'vnet'
}
}

resource aks_nodes 'Microsoft.Network/virtualNetworks/subnets@2025-05-01' = {
name: 'aks-nodes'
properties: {
addressPrefix: '10.100.0.0/22'
}
parent: vnet
}

resource alb_public 'Microsoft.Network/virtualNetworks/subnets@2025-05-01' = {
name: 'alb-public'
properties: {
addressPrefix: '10.100.4.0/24'
delegations: [
{
properties: {
serviceName: 'Microsoft.ServiceNetworking/trafficControllers'
}
name: 'Microsoft.ServiceNetworking/trafficControllers'
}
]
}
parent: vnet
dependsOn: [
aks_nodes
]
}

resource alb_admin 'Microsoft.Network/virtualNetworks/subnets@2025-05-01' = {
name: 'alb-admin'
properties: {
addressPrefix: '10.100.5.0/24'
delegations: [
{
properties: {
serviceName: 'Microsoft.ServiceNetworking/trafficControllers'
}
name: 'Microsoft.ServiceNetworking/trafficControllers'
}
]
}
parent: vnet
dependsOn: [
alb_public
]
}

output aks_nodes_Id string = aks_nodes.id

output alb_public_Id string = alb_public.id

output alb_admin_Id string = alb_admin.id

output id string = vnet.id

output name string = vnet.name
Original file line number Diff line number Diff line change
Expand Up @@ -31,124 +31,4 @@
}
}
},
"angular": {
"type": "container.v1",
"build": {
"context": "../AspireJavaScript.Angular",
"dockerfile": "../AspireJavaScript.Angular/Dockerfile"
},
"env": {
"NODE_ENV": "production",
"WEATHERAPI_HTTP": "{weatherapi.bindings.http.url}",
"services__weatherapi__http__0": "{weatherapi.bindings.http.url}",
"WEATHERAPI_HTTPS": "{weatherapi.bindings.https.url}",
"services__weatherapi__https__0": "{weatherapi.bindings.https.url}",
"PORT": "{angular.bindings.http.targetPort}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"targetPort": 8000,
"external": true
}
}
},
"react": {
"type": "container.v1",
"build": {
"context": "../AspireJavaScript.React",
"dockerfile": "../AspireJavaScript.React/Dockerfile"
},
"env": {
"NODE_ENV": "production",
"WEATHERAPI_HTTP": "{weatherapi.bindings.http.url}",
"services__weatherapi__http__0": "{weatherapi.bindings.http.url}",
"WEATHERAPI_HTTPS": "{weatherapi.bindings.https.url}",
"services__weatherapi__https__0": "{weatherapi.bindings.https.url}",
"BROWSER": "none",
"PORT": "{react.bindings.http.targetPort}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"targetPort": 8001,
"external": true
}
}
},
"vue": {
"type": "container.v1",
"build": {
"context": "../AspireJavaScript.Vue",
"dockerfile": "../AspireJavaScript.Vue/Dockerfile"
},
"env": {
"NODE_ENV": "production",
"WEATHERAPI_HTTP": "{weatherapi.bindings.http.url}",
"services__weatherapi__http__0": "{weatherapi.bindings.http.url}",
"WEATHERAPI_HTTPS": "{weatherapi.bindings.https.url}",
"services__weatherapi__https__0": "{weatherapi.bindings.https.url}",
"PORT": "{vue.bindings.http.targetPort}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"targetPort": 8002,
"external": true
}
}
},
"reactvite": {
"type": "container.v1",
"build": {
"context": "../AspireJavaScript.Vite",
"dockerfile": "reactvite.Dockerfile",
"buildOnly": true
},
"env": {
"NODE_ENV": "production",
"PORT": "{reactvite.bindings.http.targetPort}",
"WEATHERAPI_HTTP": "{weatherapi.bindings.http.url}",
"services__weatherapi__http__0": "{weatherapi.bindings.http.url}",
"WEATHERAPI_HTTPS": "{weatherapi.bindings.https.url}",
"services__weatherapi__https__0": "{weatherapi.bindings.https.url}",
"BROWSER": "none"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"targetPort": 8003,
"external": true
}
}
},
"node": {
"type": "container.v1",
"build": {
"context": "../AspireJavaScript.NodeApp",
"dockerfile": "node.Dockerfile"
},
"env": {
"NODE_ENV": "production",
"PORT": "{node.bindings.http.targetPort}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"targetPort": 8004,
"external": true
}
}
}
}
}
"angular": {
Loading