Skip to content

Instantly share code, notes, and snippets.

@mdlindsey
Created January 21, 2021 15:59
Show Gist options
  • Save mdlindsey/cd8c4bdb966135bea113f668260ab90e to your computer and use it in GitHub Desktop.
Save mdlindsey/cd8c4bdb966135bea113f668260ab90e to your computer and use it in GitHub Desktop.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"existingStorageAccountResourceGroupName": {
"type": "string",
"metadata": {
"description": "Resource group for existing storage account"
}
},
"existingStorageAccountName": {
"type": "string",
"metadata": {
"description": "Name of existing storage account"
}
},
"existingFileShareName1": {
"type": "string",
"metadata": {
"description": "Existing file-share name to mount for SFTP User #1"
}
},
"sftpUser1": {
"type": "string",
"metadata": {
"description": "Username for SFTP User #1"
}
},
"sftpPassword1": {
"type": "securestring",
"metadata": {
"description": "Password for SFTP User #1"
}
},
"existingFileShareName2": {
"type": "string",
"metadata": {
"description": "Existing file-share name to mount for SFTP User #2"
}
},
"sftpUser2": {
"type": "string",
"metadata": {
"description": "Username for SFTP User #2"
}
},
"sftpPassword2": {
"type": "securestring",
"metadata": {
"description": "Password for SFTP User #2"
}
},
"existingFileShareName3": {
"type": "string",
"metadata": {
"description": "Existing file-share name to mount for SFTP User #3"
}
},
"sftpUser3": {
"type": "string",
"metadata": {
"description": "Username for SFTP User #3"
}
},
"sftpPassword3": {
"type": "securestring",
"metadata": {
"description": "Password for SFTP User #3"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Primary location for resources"
}
},
"containerName": {
"type": "string",
"defaultValue": "sftp-container",
"metadata": {
"description": "Container name for the SFTP container instance"
}
},
"containerGroupName": {
"type": "string",
"defaultValue": "sftp-container-group",
"metadata": {
"description": "Instance name for the SFTP container group"
}
},
"dnsNameLabel": {
"type": "string",
"defaultValue": "sftpfileshare",
"metadata": {
"description": "Subdomain URL for the fileshare(s)"
}
}
},
"variables": {
"sftpContainerName": "[parameters('containerName')]",
"sftpContainerGroupName": "[parameters('containerGroupName')]",
"sftpContainerImage": "atmoz/sftp:latest",
"sftpEnvVariable": "[concat(parameters('sftpUser1'), ':', parameters('sftpPassword1'), ':::upload ', parameters('sftpUser2'), ':', parameters('sftpPassword2'), ':::upload', parameters('sftpUser3'), ':', parameters('sftpPassword3'), ':::upload')]",
"storageAccountId": "[resourceId(parameters('existingStorageAccountResourceGroupName'), 'Microsoft.Storage/storageAccounts', parameters('existingStorageAccountName'))]"
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"name": "pid-18f281fe-d1e1-502c-8b87-d945383dc75b",
"apiVersion": "2018-05-01",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": []
}
}
},
{
"type": "Microsoft.ContainerInstance/containerGroups",
"name": "[variables('sftpContainerGroupName')]",
"apiVersion": "2018-10-01",
"location": "[parameters('location')]",
"properties": {
"containers": [
{
"name": "[variables('sftpContainerName')]",
"properties": {
"image": "[variables('sftpContainerImage')]",
"environmentVariables": [
{
"name": "SFTP_USERS",
"secureValue": "[variables('sftpEnvVariable')]"
}
],
"resources": {
"requests": {
"cpu": 2,
"memoryInGB": 1
}
},
"ports": [
{
"port": 22
}
],
"volumeMounts": [
{
"mountPath": "[concat('/home/', parameters('sftpUser1'), '/upload')]",
"name": "sftpvolume1",
"readOnly": false
},
{
"mountPath": "[concat('/home/', parameters('sftpUser2'), '/upload')]",
"name": "sftpvolume2",
"readOnly": false
},
{
"mountPath": "[concat('/home/', parameters('sftpUser3'), '/upload')]",
"name": "sftpvolume3",
"readOnly": false
}
]
}
}
],
"osType": "Linux",
"ipAddress": {
"type": "Public",
"dnsNameLabel": "[parameters('dnsNameLabel')]",
"ports": [
{
"protocol": "TCP",
"port": 22
}
]
},
"restartPolicy": "OnFailure",
"volumes": [
{
"name": "sftpvolume1",
"azureFile": {
"readOnly": false,
"shareName": "[parameters('existingFileShareName1')]",
"storageAccountName": "[parameters('existingStorageAccountName')]",
"storageAccountKey": "[listKeys(variables('storageAccountId'),'2018-02-01').keys[0].value]"
}
},
{
"name": "sftpvolume2",
"azureFile": {
"readOnly": false,
"shareName": "[parameters('existingFileShareName2')]",
"storageAccountName": "[parameters('existingStorageAccountName')]",
"storageAccountKey": "[listKeys(variables('storageAccountId'),'2018-02-01').keys[0].value]"
}
},
{
"name": "sftpvolume3",
"azureFile": {
"readOnly": false,
"shareName": "[parameters('existingFileShareName3')]",
"storageAccountName": "[parameters('existingStorageAccountName')]",
"storageAccountKey": "[listKeys(variables('storageAccountId'),'2018-02-01').keys[0].value]"
}
}
]
}
}
],
"outputs": {
"containerIPv4Address": {
"type": "string",
"value": "[reference(resourceId('Microsoft.ContainerInstance/containerGroups/', variables('sftpContainerGroupName'))).ipAddress.ip]"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment