diff --git a/create-aci-sftp-server-and-azure-files-in-vnet/azuredeploy.json b/create-aci-sftp-server-and-azure-files-in-vnet/azuredeploy.json new file mode 100644 index 0000000..95c860e --- /dev/null +++ b/create-aci-sftp-server-and-azure-files-in-vnet/azuredeploy.json @@ -0,0 +1,289 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "vnetName": { + "defaultValue": "aci-vnet", + "type": "String", + "metadata": { + "description": "VNet name" + } + }, + "vnetAddressPrefix": { + "defaultValue": "10.0.0.0/16", + "type": "String", + "metadata": { + "description": "Address prefix" + } + }, + "subnetAddressPrefix": { + "defaultValue": "10.0.0.0/24", + "type": "String", + "metadata": { + "description": "Subnet prefix" + } + }, + "subnetName": { + "defaultValue": "aci-subnet", + "type": "String", + "metadata": { + "description": "Subnet name" + } + }, + "storageAccountType": { + "defaultValue": "Standard_LRS", + "allowedValues": [ + "Standard_LRS", + "Standard_GRS" + ], + "type": "String", + "metadata": { + "description": "Storage account type" + } + }, + "fileShareName": { + "defaultValue": "sftpfileshare", + "type": "String", + "metadata": { + "description": "Name of file share to be created" + } + }, + "sftpUser": { + "type": "String", + "metadata": { + "description": "Username to use for SFTP access" + } + }, + "sftpPassword": { + "type": "SecureString", + "metadata": { + "description": "Password to use for SFTP access" + } + }, + "location": { + "defaultValue": "[resourceGroup().location]", + "type": "String", + "metadata": { + "description": "Primary location for resources" + } + }, + "containerGroupDNSLabel": { + "defaultValue": "[uniqueString(resourceGroup().id, deployment().name)]", + "type": "String", + "metadata": { + "description": "DNS label for container group" + } + } + }, + "variables": { + "networkProfileName": "aci-networkProfile", + "interfaceConfigName": "eth0", + "interfaceIpConfig": "ipconfigprofile1", + "cliContainerName": "create-share", + "cliContainerGroupName": "create-share-group", + "cliContainerImage": "microsoft/azure-cli:latest", + "sftpContainerName": "sftp", + "sftpContainerGroupName": "sftp-group", + "sftpContainerImage": "atmoz/sftp:latest", + "sftpEnvVariable": "[concat(parameters('sftpUser'), ':', parameters('sftpPassword'), ':1001')]", + "storageAccountName": "[concat('sftpstg', uniqueString(resourceGroup().id))]" + }, + "resources": [ + { + "type": "Microsoft.Network/virtualNetworks", + "apiVersion": "2020-05-01", + "name": "[parameters('vnetName')]", + "location": "[parameters('location')]", + "properties": { + "addressSpace": { + "addressPrefixes": [ + "[parameters('vnetAddressPrefix')]" + ] + }, + "subnets": [ + { + "name": "[parameters('subnetName')]", + "properties": { + "addressPrefix": "[parameters('subnetAddressPrefix')]", + "delegations": [ + { + "name": "DelegationService", + "properties": { + "serviceName": "Microsoft.ContainerInstance/containerGroups" + } + } + ] + } + } + ] + } + }, + { + "type": "Microsoft.Network/networkProfiles", + "apiVersion": "2020-05-01", + "name": "[variables('networkProfileName')]", + "location": "[parameters('location')]", + "dependsOn": [ + "[resourceId('Microsoft.Network/virtualNetworks', parameters('vnetName'))]" + ], + "properties": { + "containerNetworkInterfaceConfigurations": [ + { + "name": "[variables('interfaceConfigName')]", + "properties": { + "ipConfigurations": [ + { + "name": "[variables('interfaceIpConfig')]", + "properties": { + "subnet": { + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2015-01-01", + "name": "pid-18f281fe-d1e1-502c-8b87-d945383dc75b", + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [] + } + } + }, + { + "type": "Microsoft.Storage/storageAccounts", + "apiVersion": "2018-02-01", + "name": "[variables('storageAccountName')]", + "location": "[parameters('location')]", + "sku": { + "name": "[parameters('storageAccountType')]" + }, + "kind": "Storage", + "properties": {} + }, + { + "type": "Microsoft.ContainerInstance/containerGroups", + "apiVersion": "2019-12-01", + "name": "[variables('cliContainerGroupName')]", + "location": "[parameters('location')]", + "dependsOn": [ + "[variables('storageAccountName')]", + "[resourceId('Microsoft.Network/networkProfiles', variables('networkProfileName'))]" + ], + "properties": { + "containers": [ + { + "name": "[variables('cliContainerName')]", + "properties": { + "image": "[variables('cliContainerImage')]", + "command": [ + "az", + "storage", + "share", + "create", + "--name", + "[parameters('fileShareName')]" + ], + "environmentVariables": [ + { + "name": "AZURE_STORAGE_KEY", + "value": "[listKeys(variables('storageAccountName'),'2018-02-01').keys[0].value]" + }, + { + "name": "AZURE_STORAGE_ACCOUNT", + "value": "[variables('storageAccountName')]" + } + ], + "resources": { + "requests": { + "cpu": 1, + "memoryInGB": 1 + } + } + } + } + ], + "restartPolicy": "OnFailure", + "networkProfile": { + "id": "[resourceId('Microsoft.Network/networkProfiles', variables('networkProfileName'))]" + }, + "osType": "Linux" + } + }, + { + "type": "Microsoft.ContainerInstance/containerGroups", + "apiVersion": "2019-12-01", + "name": "[variables('sftpContainerGroupName')]", + "location": "[parameters('location')]", + "dependsOn": [ + "[variables('cliContainerGroupName')]", + "[resourceId('Microsoft.Network/networkProfiles', variables('networkProfileName'))]" + ], + "properties": { + "containers": [ + { + "name": "[variables('sftpContainerName')]", + "properties": { + "image": "[variables('sftpContainerImage')]", + "environmentVariables": [ + { + "name": "SFTP_USERS", + "value": "[variables('sftpEnvVariable')]" + } + ], + "resources": { + "requests": { + "cpu": 2, + "memoryInGB": 1 + } + }, + "ports": [ + { + "port": 22 + } + ], + "volumeMounts": [ + { + "mountPath": "[concat('/home/', parameters('sftpUser'), '/upload')]", + "name": "sftpvolume", + "readOnly": false + } + ] + } + } + ], + "osType": "Linux", + "networkProfile": { + "id": "[resourceId('Microsoft.Network/networkProfiles', variables('networkProfileName'))]" + }, + "restartPolicy": "OnFailure", + "volumes": [ + { + "name": "sftpvolume", + "azureFile": { + "readOnly": false, + "shareName": "[parameters('fileShareName')]", + "storageAccountName": "[variables('storageAccountName')]", + "storageAccountKey": "[listKeys(variables('storageAccountName'),'2018-02-01').keys[0].value]" + } + } + ] + } + } + ], + "outputs": { + "containerDNSLabel": { + "type": "String", + "value": "[concat(parameters('containerGroupDNSLabel'), '.', parameters('location'), '.azurecontainer.io')]" + } + } +} \ No newline at end of file diff --git a/create-aci-sftp-server-and-azure-files-in-vnet/azuredeploy.parameters.json b/create-aci-sftp-server-and-azure-files-in-vnet/azuredeploy.parameters.json new file mode 100644 index 0000000..2ab3456 --- /dev/null +++ b/create-aci-sftp-server-and-azure-files-in-vnet/azuredeploy.parameters.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "sftpUser": { + "value": "GEN-UNIQUE-6" + }, + "sftpPassword": { + "value": "GEN-PASSWORD" + } + } +} \ No newline at end of file diff --git a/create-aci-sftp-server-and-azure-files-in-vnet/metadata.json b/create-aci-sftp-server-and-azure-files-in-vnet/metadata.json new file mode 100644 index 0000000..014bde6 --- /dev/null +++ b/create-aci-sftp-server-and-azure-files-in-vnet/metadata.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://aka.ms/azure-quickstart-templates-metadata-schema#", + "type": "QuickStart", + "itemDisplayName": "Create an on-demand SFTP Server with persistent storage in VNET", + "description": "This template demonstrates an on-demand SFTP server using an Azure Container Instance (ACI) within a VNET.", + "summary": "Create an on-demand SFTP Server with persistent storage", + "githubUsername": "bhummerstone", + "dateUpdated": "2018-11-02" + } + + \ No newline at end of file