-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontainergroups.bicep
86 lines (76 loc) · 2.39 KB
/
containergroups.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
param name string
@description('Specify which type of dev environment to deploy')
@allowed([
'AzureCLI'
'AzurePowerShell'
])
param type string = 'AzureCLI'
@description('Use to overide the version to use for Azure CLI or AzurePowerShell')
param toolVersion string = ''
@description('This is the path in the container instance where it\'s mounted to the file share.')
param mountPath string = '/mnt/azscripts/azscriptinput'
@description('Time in second before the container instance is suspended')
param sessionTime string = '1800'
param fileShareName string
param storageName string
param storageId string
param location string = resourceGroup().location
// Specifies which version to use if no specific toolVersion is provided (Azure CLI latest or Azure PowerShell 5.6)
var version = (type == 'AzureCLI' && toolVersion == '' ? 'latest' : type == 'AzurePowerShell' && toolVersion == '' ? '5.6' : toolVersion)
var azcliImage = 'mcr.microsoft.com/azure-cli:${version}'
var azpwshImage = 'mcr.microsoft.com/azuredeploymentscripts-powershell:az${version}'
var azpwshCommand = [
'/bin/sh'
'-c'
'pwsh -c \'Start-Sleep -Seconds ${sessionTime}\''
]
var azcliCommand = [
'/bin/bash'
'-c'
'echo hello; sleep ${sessionTime}'
]
resource containerGroupName 'Microsoft.ContainerInstance/containerGroups@2019-12-01' = {
name: name
location: location
properties: {
containers: [
{
name: '${name}cg'
properties: {
image: type == 'AzureCLI' ? azcliImage : type == 'AzurePowerShell' ? azpwshImage : ''
resources: {
requests: {
cpu: 1
memoryInGB: 2
}
}
ports: [
{
protocol: 'TCP'
port: 80
}
]
volumeMounts: [
{
name: 'filesharevolume'
mountPath: mountPath
}
]
command: type == 'AzureCLI' ? azcliCommand : type == 'AzurePowerShell' ? azpwshCommand : null
}
}
]
osType: 'Linux'
volumes: [
{
name: 'filesharevolume'
azureFile: {
readOnly: false
shareName: fileShareName
storageAccountName: storageName
storageAccountKey: listKeys(storageId, '2019-06-01').keys[0].value
}
}
]
}
}