-
Notifications
You must be signed in to change notification settings - Fork 0
/
aci_start.ps1
74 lines (65 loc) · 2.39 KB
/
aci_start.ps1
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
# Azure function to start Azure Container Instance
param($Timer)
$subscriptionId = "my-subscriptionId"
$tenantId = "my-tenant-id"
$storageResourceGroupName = 'minecraft'
$resourceGroupName = "minecraft"
$containerGroupName = "minecraft-dropper"
$dnsNameLabel = "mc-dropper"
$shareName = "dropper"
$storageAccountName = "mystorage-persistance-volume"
$location = "canadacentral"
$environmentVariables = @{
EULA = "TRUE";
OPS = "admin_account";
VERSION = "1.13.2";
MAX_PLAYERS="4";
ONLINE_MODE="FALSE";
ALLOW_FLIGHT="TRUE";
MODE="adventure";
MEMORY="1G";
WORLD="https://www.minecraftmaps.com/dropper-maps/world-drop/download"
}
Select-AzSubscription -SubscriptionID $subscriptionId -TenantID $tenantId
# get storage account
$storageAccount = Get-AzStorageAccount `
-ResourceGroupName $storageResourceGroupName `
-Name $storageAccountName
if ($storageAccount -eq $null) {
# create the storage account
$storageAccount = New-AzStorageAccount `
-ResourceGroupName $storageResourceGroupName `
-Name $storageAccountName `
-SkuName Standard_LRS `
-Location $location
}
# check if the file share already exists
$share = Get-AzStorageShare `
-Name $shareName -Context $storageAccount.Context `
-ErrorAction SilentlyContinue
if ($share -eq $null) {
# create the share
$share = New-AzStorageShare `
-Name $shareName `
-Context $storageAccount.Context
}
# get the credentials
$storageAccountKeys = Get-AzStorageAccountKey `
-ResourceGroupName $storageResourceGroupName `
-Name $storageAccountName
$storageAccountKey = $storageAccountKeys[0].Value# check if storage account exists
$storageAccountKeySecureString = ConvertTo-SecureString $storageAccountKey -AsPlainText -Force
$storageAccountCredentials = New-Object System.Management.Automation.PSCredential ($storageAccountName, $storageAccountKeySecureString)
New-AzContainerGroup -ResourceGroupName $resourceGroupName `
-Name $containerGroupName `
-Image "itzg/minecraft-server" `
-AzureFileVolumeAccountCredential $storageAccountCredentials `
-AzureFileVolumeShareName $shareName `
-AzureFileVolumeMountPath "/data" `
-IpAddressType Public `
-OsType Linux `
-DnsNameLabel $dnsNameLabel `
-Port 25565 `
-Cpu 1 `
-MemoryInGB 2 `
-EnvironmentVariable $environmentVariables