Skip to content

Instantly share code, notes, and snippets.

@yazdipour
Last active February 11, 2021 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yazdipour/cbccf4c7768375555024f364d5a03280 to your computer and use it in GitHub Desktop.
Save yazdipour/cbccf4c7768375555024f364d5a03280 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"
}
},
"existingUploadFileShareName": {
"type": "string",
"metadata": {
"description": "Name of existing file share to be mounted for uploads"
}
},
"existingSSHKeysFileShareName1": {
"type": "string",
"metadata": {
"description": "[user1] Name of existing file share to be mounted for user ssh keys"
}
},
"existingSSHKeysFileShareName2": {
"type": "string",
"metadata": {
"description": "[user2] Name of existing file share to be mounted for user ssh keys"
}
},
"sftpUser1": {
"type": "string",
"metadata": {
"description": "First username to use for SFTP access"
}
},
"sftpUser2": {
"type": "string",
"metadata": {
"description": "Second username to use for SFTP access"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Primary location for resources"
}
},
"containerRegistry": {
"type": "string",
"defaultValue": "vasanthtt/sftp:latest",
"metadata": {
"description": "Container registry for custom image"
}
},
"sftpDNSName": {
"type": "string",
"metadata": {
"description": "DNS for SFTP"
}
},
"sftpGroupName": {
"defaultValue": "sftp-group",
"type": "string",
"metadata": {
"description": "DNS for SFTP"
}
}
},
"variables": {
"sftpContainerName": "sftp",
"sftpContainerGroupName": "[parameters('sftpGroupName')]",
"sftpDNSLabel": "[parameters('sftpDNSName')]",
"sftpContainerImage": "[parameters('containerRegistry')]",
"sftpEnvVariable": "[concat(parameters('sftpUser1'), '::::upload ', parameters('sftpUser2'), '::::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",
"value": "[variables('sftpEnvVariable')]"
}
],
"resources": {
"requests": {
"cpu": 2,
"memoryInGB": 2
}
},
"ports": [
{
"port": 22
}
],
"volumeMounts": [
{
"mountPath": "[concat('/home/', parameters('sftpUser1'), '/upload')]",
"name": "sftpvolume1",
"readOnly": false
},
{
"mountPath": "[concat('/home/', parameters('sftpUser1'), '/.ssh/keys')]",
"name": "sshkeyvolume1",
"readOnly": true
},
{
"mountPath": "[concat('/home/', parameters('sftpUser2'), '/upload')]",
"name": "sftpvolume2",
"readOnly": false
},
{
"mountPath": "[concat('/home/', parameters('sftpUser2'), '/.ssh/keys')]",
"name": "sshkeyvolume2",
"readOnly": true
}
]
}
}
],
"osType": "Linux",
"ipAddress": {
"type": "Public",
"ports": [
{
"protocol": "TCP",
"port": 22
}
],
"dnsNameLabel": "[variables('sftpDNSLabel')]"
},
"restartPolicy": "OnFailure",
"volumes": [
{
"name": "sftpvolume1",
"azureFile": {
"readOnly": false,
"shareName": "[parameters('existingUploadFileShareName')]",
"storageAccountName": "[parameters('existingStorageAccountName')]",
"storageAccountKey": "[listKeys(variables('storageAccountId'),'2018-02-01').keys[0].value]"
}
},
{
"name": "sftpvolume2",
"azureFile": {
"readOnly": false,
"shareName": "[parameters('existingUploadFileShareName')]",
"storageAccountName": "[parameters('existingStorageAccountName')]",
"storageAccountKey": "[listKeys(variables('storageAccountId'),'2018-02-01').keys[0].value]"
}
},
{
"name": "sshkeyvolume1",
"azureFile": {
"readOnly": true,
"shareName": "[parameters('existingSSHKeysFileShareName1')]",
"storageAccountName": "[parameters('existingStorageAccountName')]",
"storageAccountKey": "[listKeys(variables('storageAccountId'),'2018-02-01').keys[0].value]"
}
},
{
"name": "sshkeyvolume2",
"azureFile": {
"readOnly": true,
"shareName": "[parameters('existingSSHKeysFileShareName2')]",
"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.fqdn]"
}
}
}
{
"$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"
}
},
"existingUploadFileShareName": {
"type": "string",
"metadata": {
"description": "Name of existing file share to be mounted for uploads"
}
},
"existingSSHKeysFileShareName": {
"type": "string",
"metadata": {
"description": "Name of existing file share to be mounted for user ssh keys"
}
},
"sftpUser": {
"type": "string",
"metadata": {
"description": "Username to use for SFTP access"
}
},
"sftpPassword": {
"type": "string",
"metadata": {
"description": "Password to use for SFTP access"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Primary location for resources"
}
},
"containerRegistry": {
"type": "string",
"defaultValue": "vasanthtt/sftp:latest",
"metadata": {
"description": "Container registry for custom image"
}
},
"sftpDNSName": {
"type": "string",
"metadata": {
"description": "DNS for SFTP"
}
},
"sftpGroupName": {
"defaultValue": "sftp-group",
"type": "string",
"metadata": {
"description": "DNS for SFTP"
}
}
},
"variables": {
"sftpContainerName": "sftp",
"sftpContainerGroupName": "[parameters('sftpGroupName')]",
"sftpDNSLabel": "[parameters('sftpDNSName')]",
"sftpContainerImage": "[parameters('containerRegistry')]",
"sftpEnvVariable": "[concat(parameters('sftpUser'),':',parameters('sftpPassword'),':1001')]",
"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",
"value": "[variables('sftpEnvVariable')]"
}
],
"resources": {
"requests": {
"cpu": 2,
"memoryInGB": 2
}
},
"ports": [
{
"port": 22
}
],
"volumeMounts": [
{
"mountPath": "[concat('/home/', parameters('sftpUser'), '/upload')]",
"name": "sftpvolume",
"readOnly": false
},
{
"mountPath": "[concat('/home/', parameters('sftpUser'), '/.ssh/keys')]",
"name": "sshkeyvolume",
"readOnly": true
}
]
}
}
],
"osType": "Linux",
"ipAddress": {
"type": "Public",
"ports": [
{
"protocol": "TCP",
"port": 22
}
],
"dnsNameLabel": "[variables('sftpDNSLabel')]"
},
"restartPolicy": "OnFailure",
"volumes": [
{
"name": "sftpvolume",
"azureFile": {
"readOnly": false,
"shareName": "[parameters('existingUploadFileShareName')]",
"storageAccountName": "[parameters('existingStorageAccountName')]",
"storageAccountKey": "[listKeys(variables('storageAccountId'),'2018-02-01').keys[0].value]"
}
},
{
"name": "sshkeyvolume",
"azureFile": {
"readOnly": true,
"shareName": "[parameters('existingSSHKeysFileShareName')]",
"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.fqdn]"
}
}
}
{
"$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": "Name of existing file share to be mounted for first user"
}
},
"existingFileShareName2": {
"type": "string",
"metadata": {
"description": "Name of existing file share to be mounted for second user"
}
},
"sftpUser1": {
"type": "string",
"metadata": {
"description": "First username to use for SFTP access"
}
},
"sftpPassword1": {
"type": "securestring",
"metadata": {
"description": "Password to use for first user's SFTP access"
}
},
"sftpUser2": {
"type": "string",
"metadata": {
"description": "Second username to use for SFTP access"
}
},
"sftpPassword2": {
"type": "securestring",
"metadata": {
"description": "Password to use for second user's SFTP access"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Primary location for resources"
}
}
},
"variables": {
"sftpContainerName": "sftp",
"sftpContainerGroupName": "sftp-group",
"sftpContainerImage": "atmoz/sftp:latest",
"sftpEnvVariable": "[concat(parameters('sftpUser1'), ':', parameters('sftpPassword1'), ':::upload ', parameters('sftpUser2'), ':', parameters('sftpPassword2'), ':::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
}
]
}
}
],
"osType": "Linux",
"ipAddress": {
"type": "Public",
"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]"
}
}
]
}
}
],
"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