-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontainer-app-dynamic-sessions.bicep
57 lines (52 loc) · 2.31 KB
/
container-app-dynamic-sessions.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { roleAssignmentInfo } from '../security/managed-identity.bicep'
@description('Name of the resource.')
param name string
@description('Location to deploy the resource. Defaults to the location of the resource group.')
param location string = resourceGroup().location
@description('Tags for the resource.')
param tags object = {}
@description('The number of seconds to wait before scaling down the pool after the last session is completed. Must be greater than or equal to 300 seconds. Defaults to 300 seconds.')
@minValue(300)
param cooldownPeriodInSeconds int = 300
@description('The maximum number of concurrent sessions that can be created in the pool. Defaults to 20.')
param maxConcurrentSessions int = 20
@description('The number of sessions to keep ready in the pool. Defaults to 1.')
param readySessionInstances int = 1
@description('Role assignments to create for the dynamic session pool.')
param roleAssignments roleAssignmentInfo[] = []
resource dynamicSession 'Microsoft.App/sessionPools@2024-10-02-preview' = {
name: name
location: location
tags: tags
properties: {
containerType: 'PythonLTS'
dynamicPoolConfiguration: {
cooldownPeriodInSeconds: cooldownPeriodInSeconds
executionType: 'Timed'
}
poolManagementType: 'Dynamic'
scaleConfiguration: {
maxConcurrentSessions: maxConcurrentSessions
readySessionInstances: readySessionInstances
}
}
}
resource assignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = [
for roleAssignment in roleAssignments: {
name: guid(dynamicSession.id, roleAssignment.principalId, roleAssignment.roleDefinitionId)
scope: dynamicSession
properties: {
principalId: roleAssignment.principalId
roleDefinitionId: roleAssignment.roleDefinitionId
principalType: roleAssignment.principalType
}
}
]
@description('The deployed dynamic session pool resource.')
output resource resource = dynamicSession
@description('ID for the deployed dynamic session pool resource.')
output id string = dynamicSession.id
@description('Name for the deployed dynamic session pool resource.')
output name string = dynamicSession.name
@description('Pool management endpoint for the dynamic session pool.')
output endpoint string = dynamicSession.properties.poolManagementEndpoint