Last active
December 13, 2021 07:51
-
-
Save johanburati/1942a2d63e95ec677c0b81eca2c92274 to your computer and use it in GitHub Desktop.
Create SFTP enabled storage on Azure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"storageAccountType": { | |
"type": "string", | |
"defaultValue": "Standard_LRS", | |
"allowedValues": ["Standard_LRS", "Standard_ZRS"], | |
"metadata": { "description": "Storage Account type" } | |
}, | |
"location": { | |
"type": "string", | |
"defaultValue": "eastus2", | |
"allowedValues": ["westeurope", "northcentralus", "eastus2", "eastus2euap", "centralus", "canadaeast", "canadacentral", "northeurope", "australiaeast", "switzerlandnorth", "germanywestcentral", "eastasia", "francecentral"], | |
"metadata": { "description": "Region" } | |
}, | |
"storageAccountName": { | |
"type": "string", | |
"metadata": { "description": "Storage Account Name" } | |
}, | |
"userName": { | |
"type": "string", | |
"metadata": { "description": "Username of primary user" } | |
}, | |
"homeDirectory": { | |
"type": "string", | |
"metadata": { "description": "Home directory of primary user. Should be a container." } | |
}, | |
"publicKey": { | |
"type": "string", | |
"metadata": { "description": "SSH Public Key for primary user." } | |
} | |
}, | |
"resources": [ | |
{ | |
"type": "Microsoft.Storage/storageAccounts", | |
"apiVersion": "2019-06-01", | |
"name": "[parameters('storageAccountName')]", | |
"location": "[parameters('location')]", | |
"sku": { | |
"name": "[parameters('storageAccountType')]" | |
}, | |
"kind": "StorageV2", | |
"properties": { | |
"isHnsEnabled": true, | |
"isLocalUserEnabled": true, | |
"isSftpEnabled": true | |
}, | |
"resources": [ | |
{ | |
"type": "blobServices/containers", | |
"apiVersion": "2019-06-01", | |
"name": "[concat('default/', parameters('homeDirectory'))]", | |
"dependsOn": ["[parameters('storageAccountName')]"], | |
"properties": { | |
"publicAccess": "None" | |
} | |
}, | |
{ | |
"type": "localUsers", | |
"apiVersion": "2019-06-01", | |
"name": "[parameters('userName')]", | |
"properties": { | |
"permissionScopes": [ | |
{ | |
"permissions": "rcwdl", | |
"service": "blob", | |
"resourceName": "[parameters('homeDirectory')]" | |
} | |
], | |
"homeDirectory": "[parameters('homeDirectory')]", | |
"sshAuthorizedKeys": [ | |
{ | |
"description": "localuser public key", | |
"key": "[parameters('publicKey')]" | |
} | |
], | |
"hasSharedKey": false | |
}, | |
"dependsOn": ["[parameters('storageAccountName')]"] | |
} | |
] | |
} | |
], | |
"outputs": { | |
"defaultContainer": { | |
"type": "string", | |
"value": "[parameters('homeDirectory')]" | |
}, | |
"user": { | |
"type": "object", | |
"value": "[reference( | |
resourceId('Microsoft.Storage/storageAccounts/localUsers', parameters('storageAccountName'), parameters('userName')) | |
)]" | |
}, | |
"keys": { | |
"type": "object", | |
"value": "[listKeys(resourceId('Microsoft.Storage/storageAccounts/localUsers', parameters('storageAccountName'), parameters('userName')), '2019-06-01')]" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment