{ "$schema": "https://schema.management.azure.com/schemas/2018-05-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "vmName": { "type": "string", "metadata": { "description": "The name of the Virtual Machine. Limit 15 characters. (Reference: https://support.microsoft.com/en-us/kb/909264)" }, "defaultValue": "fileserver" }, "fileServerVirtualMachineSize": { "type": "string", "defaultValue": "Standard_F2s", "allowedValues": [ "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F2s_v2", "Standard_F4s_v2", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2" ], "metadata": { "description": "Size of VM" } }, "dnsNameForPublicIP": { "type": "string", "defaultValue": "appservicefileshare", "maxLength": 63, "metadata": { "description": "Unique DNS Name for the Public IP used to access the file share.It must be lowercase. It should match the following regular expression, or it will raise an error: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$" } }, "adminUsername": { "type": "string", "defaultValue": "fileshareadmin", "metadata": { "description": "File server Admin user" } }, "adminPassword": { "type": "securestring", "metadata": { "description": "File server Admin password" } }, "fileShareOwner": { "type": "string", "defaultValue": "fileshareowner", "metadata": { "description": "fileshare owner username" } }, "fileShareOwnerPassword": { "type": "securestring", "metadata": { "description": "fileshare owner password" } }, "fileShareUser": { "type": "string", "defaultValue": "fileshareuser", "metadata": { "description": "fileshare user" } }, "fileShareUserPassword": { "type": "securestring", "metadata": { "description": "fileshare user password" } }, "vmExtensionScriptLocation": { "type": "string", "defaultValue": "https://raw.githubusercontent.com/mattmcspirit/azurestack/master/deployment/templates/FileServer/scripts/", "metadata": { "description": "File Server extension script Url" } } }, "variables": { "storageAccountResourceGroup": "[resourceGroup().name]", "powershell_fileShareOwner": "[concat('base64:', base64(parameters('fileShareOwner')))]", "powershell_fileShareOwnerPassword": "[concat('base64:', base64(parameters('fileShareOwnerPassword')))]", "powershell_fileShareUser": "[concat('base64:', base64(parameters('fileShareUser')))]", "powershell_fileShareUserPassword": "[concat('base64:', base64(parameters('fileShareUserPassword')))]", "publicIPAddressName": "[concat(parameters('vmName'),'_ip')]", "publicIPAddressType": "Static", "virtualNetworkName": "[concat(parameters('vmName'),'_vnet')]", "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]", "vnetAddressPrefix": "10.100.0.0/16", "subnetName": "[concat(parameters('vmName'),'_subnet')]", "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", "subnetPrefix": "10.100.0.0/24", "publisher": "MicrosoftWindowsServer", "offer": "WindowsServer", "sku": "2016-Datacenter-Server-Core", "version": "latest", "managedDiskAccountType": "Premium_LRS", "osDiskName": "[toLower(concat(parameters('vmName'), '_osdisk'))]", "randomGUID": "[substring(uniqueString(subscription().subscriptionId, resourceGroup().id, parameters('vmName'),parameters('adminUsername')),0,4)]", "diagStorageAccountName": "[concat(parameters('vmName'),'diag', variables('randomGUID'))]", "nicName": "[concat(parameters('vmName'),'_nic')]", "nsgName": "[concat(parameters('vmName'),'_nsg')]", "scriptParameters": "[concat('-fileShareOwnerUserName ',variables('powershell_fileShareOwner'),' -fileShareOwnerPassword \"',variables('powershell_fileShareOwnerPassword'),'\"',' -fileShareUserUserName ',variables('powershell_fileShareUser'),' -fileShareUserPassword \"',variables('powershell_fileShareUserPassword'),'\"')]" }, "resources": [ { "apiVersion": "2017-10-01", "type": "Microsoft.Storage/storageAccounts", "name": "[variables('diagStorageAccountName')]", "location": "[resourceGroup().location]", "kind": "Storage", "sku": { "name": "Standard_LRS" } }, { "apiVersion": "2017-10-01", "type": "Microsoft.Network/networkSecurityGroups", "name": "[variables('nsgName')]", "location": "[resourceGroup().location]", "properties": { "securityRules": [ { "name": "RDP", "properties": { "description": "AllowRDP", "protocol": "Tcp", "sourcePortRange": "*", "destinationPortRange": "3389", "sourceAddressPrefix": "*", "destinationAddressPrefix": "*", "access": "Allow", "priority": 100, "direction": "Inbound" } }, { "name": "SMB", "properties": { "description": "AllowSMBTraffic", "protocol": "*", "sourcePortRange": "*", "destinationPortRange": "445", "sourceAddressPrefix": "*", "destinationAddressPrefix": "*", "access": "Allow", "priority": 200, "direction": "Inbound" } } ] } }, { "apiVersion": "2017-10-01", "type": "Microsoft.Network/publicIPAddresses", "name": "[variables('publicIPAddressName')]", "location": "[resourceGroup().location]", "properties": { "publicIPAllocationMethod": "[variables('publicIPAddressType')]", "dnsSettings": { "domainNameLabel": "[parameters('dnsNameForPublicIP')]" } } }, { "apiVersion": "2017-10-01", "type": "Microsoft.Network/virtualNetworks", "name": "[variables('virtualNetworkName')]", "location": "[resourceGroup().location]", "properties": { "addressSpace": { "addressPrefixes": [ "[variables('vnetAddressPrefix')]" ] }, "subnets": [ { "name": "[variables('subnetName')]", "properties": { "addressPrefix": "[variables('subnetPrefix')]" } } ] } }, { "apiVersion": "2017-10-01", "type": "Microsoft.Network/networkInterfaces", "name": "[variables('nicName')]", "location": "[resourceGroup().location]", "dependsOn": [ "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]", "[concat('Microsoft.Network/networkSecurityGroups/', variables('nsgName'))]" ], "properties": { "networkSecurityGroup": { "id": "[resourceId('Microsoft.Network/networkSecurityGroups',variables('nsgName'))]" }, "ipConfigurations": [ { "name": "ipconfig1", "properties": { "privateIPAllocationMethod": "Dynamic", "publicIPAddress": { "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]" }, "subnet": { "id": "[variables('subnetRef')]" } } } ] } }, { "apiVersion": "2017-12-01", "type": "Microsoft.Compute/virtualMachines", "name": "[parameters('vmName')]", "location": "[resourceGroup().location]", "tags": { "displayName": "Standalone file server virtual machines" }, "dependsOn": [ "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" ], "properties": { "hardwareProfile": { "vmSize": "[parameters('fileServerVirtualMachineSize')]" }, "osProfile": { "computerName": "[parameters('vmName')]", "adminUsername": "[parameters('adminUsername')]", "adminPassword": "[parameters('adminPassword')]" }, "storageProfile": { "imageReference": { "publisher": "[variables('publisher')]", "offer": "[variables('offer')]", "sku": "[variables('sku')]", "version": "[variables('version')]" }, "osDisk": { "osType": "Windows", "name": "[variables('osDiskName')]", "caching": "ReadWrite", "createOption": "FromImage", "managedDisk": { "storageAccountType": "[variables('managedDiskAccountType')]" } } }, "networkProfile": { "networkInterfaces": [ { "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]" } ] }, "diagnosticsProfile": { "bootDiagnostics": { "enabled": true, "storageUri": "[reference(resourceId(variables('storageAccountResourceGroup'), 'Microsoft.Storage/storageAccounts/', variables('diagStorageAccountName'))).primaryEndpoints.blob]" } } } }, { "type": "Microsoft.Compute/virtualMachines/extensions", "name": "[concat(parameters('vmName'),'/configurefileserver')]", "apiVersion": "2017-12-01", "location": "[resourceGroup().location]", "dependsOn": [ "[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]" ], "properties": { "publisher": "Microsoft.Compute", "type": "CustomScriptExtension", "typeHandlerVersion": "1.9", "autoUpgradeMinorVersion": true, "settings": { "fileUris": [ "[concat(parameters('vmExtensionScriptLocation'), 'ConfigureFileServer.ps1')]" ] }, "protectedSettings": { "commandToExecute": "[concat('powershell.exe -ExecutionPolicy Unrestricted -File ConfigureFileServer.ps1 ',variables('scriptParameters'))]" } } } ], "outputs": { "fqdn": { "value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))).dnsSettings.fqdn]", "type": "string" }, "ipaddress": { "value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))).ipAddress]", "type": "string" } } }