-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.bicep
87 lines (72 loc) · 2.11 KB
/
main.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@description('The location where the resources will be deployed')
param location string
@description('The name of the job')
param name string
@description('The image to be used for the job')
param image string
@description('The ID of the container app environment')
param containerAppEnvId string
@description('The environment variables for the job')
param environmentVariables { name: string, value: string?, secretRef: string? }[] = []
@description('The secrets to be used in the job')
param secrets { name: string, keyVaultUrl: string, identity: 'System' }[] = []
@description('The tags to be applied to the job')
param tags object
@description('The cron expression for the job schedule (optional)')
param cronExpression string = ''
@description('The container args for the job (optional)')
param args string = ''
@description('The ID of the user-assigned managed identity')
@minLength(1)
param userAssignedIdentityId string
var isScheduled = !empty(cronExpression)
var scheduledJobProperties = {
triggerType: 'Schedule'
scheduleTriggerConfig: {
cronExpression: cronExpression
}
}
var manualJobProperties = {
triggerType: 'Manual'
manualTriggerConfig: {
parallelism: 1
replicaCompletionCount: 1
}
}
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = {
name: last(split(userAssignedIdentityId, '/'))
}
resource job 'Microsoft.App/jobs@2024-03-01' = {
name: name
location: location
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${userAssignedIdentityId}': {}
}
}
properties: {
configuration: union(
{
secrets: secrets
replicaRetryLimit: 1
replicaTimeout: 120
},
isScheduled ? scheduledJobProperties : manualJobProperties
)
environmentId: containerAppEnvId
template: {
containers: [
{
env: environmentVariables
image: image
name: name
args: empty(args) ? null : [args]
}
]
}
}
tags: tags
}
output identityPrincipalId string = managedIdentity.properties.principalId
output name string = job.name