Warning: Undefined variable $file in /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-content/plugins/fix-my-feed-rss-repair/rss-feed-fixr.php on line 14 Warning: Cannot modify header information - headers already sent by (output started at /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-content/plugins/fix-my-feed-rss-repair/rss-feed-fixr.php:14) in /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-includes/rest-api/class-wp-rest-server.php on line 1637 Warning: Cannot modify header information - headers already sent by (output started at /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-content/plugins/fix-my-feed-rss-repair/rss-feed-fixr.php:14) in /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-includes/rest-api/class-wp-rest-server.php on line 1637 Warning: Cannot modify header information - headers already sent by (output started at /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-content/plugins/fix-my-feed-rss-repair/rss-feed-fixr.php:14) in /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-includes/rest-api/class-wp-rest-server.php on line 1637 Warning: Cannot modify header information - headers already sent by (output started at /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-content/plugins/fix-my-feed-rss-repair/rss-feed-fixr.php:14) in /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-includes/rest-api/class-wp-rest-server.php on line 1637 Warning: Cannot modify header information - headers already sent by (output started at /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-content/plugins/fix-my-feed-rss-repair/rss-feed-fixr.php:14) in /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-includes/rest-api/class-wp-rest-server.php on line 1637 Warning: Cannot modify header information - headers already sent by (output started at /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-content/plugins/fix-my-feed-rss-repair/rss-feed-fixr.php:14) in /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-includes/rest-api/class-wp-rest-server.php on line 1637 Warning: Cannot modify header information - headers already sent by (output started at /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-content/plugins/fix-my-feed-rss-repair/rss-feed-fixr.php:14) in /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-includes/rest-api/class-wp-rest-server.php on line 1637 Warning: Cannot modify header information - headers already sent by (output started at /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-content/plugins/fix-my-feed-rss-repair/rss-feed-fixr.php:14) in /customers/a/e/3/tunecom.be/httpd.www/stg_ba12f/wp-includes/rest-api/class-wp-rest-server.php on line 1637 {"id":617,"date":"2020-02-28T07:22:43","date_gmt":"2020-02-28T07:22:43","guid":{"rendered":"https:\/\/www.tunecom.be\/stg_ba12f\/?p=617"},"modified":"2020-02-28T07:24:04","modified_gmt":"2020-02-28T07:24:04","slug":"moving-your-data-to-a-serverless-infrastructure-with-azure-files-and-active-directory-authentication-preview","status":"publish","type":"post","link":"https:\/\/www.tunecom.be\/stg_ba12f\/?p=617","title":{"rendered":"Moving your data to a serverless infrastructure with Azure Files and Active Directory Authentication (Preview)"},"content":{"rendered":"\n
A couple of days ago, Microsoft announced the public preview of Windows Server Active Directory authentication \/ integration for Azure Files. Make sure to check-out the introduction video<\/a> by Will Gries<\/a> (Senior Program Manager) and Thomas Maurer<\/a> (Senior Cloud Advocate) Now it’s time to integrate this with our existing Windows Server Active Directory Infrastructure<\/p>\n\n\n\n We are now able to set NTFS permissions and ACLs based on our existing Windows Server AD on an Azure Fileshare. This blogpost takes you through the necessary steps to automate <\/strong>the process <\/strong>shown below.<\/p>\n\n\n\n Before we can activate all of this, we have a couple of prerequisites:<\/p>\n\n\n\n Background info: Change the initial variables to meet your environment needs, I have chosen France Central as a region to deploy our Storage Account.<\/p>\n\n\n\n Download the script here<\/a>, or copy paste the scriptblock below. After running the script you’ll see that new or additional file shares have been created.<\/p>\n\n\n\n Since it’s still in public preview, you need to perform a couple of manual steps in order to join your Azure Storage account to your Windows Server Active Directory Domain. Looking at Azure AD Domain Services, this is an additional switch \/ parameters you need to provide in order to allow Azure AD DS authentication. I assume that the product team will try to provide the same type of deployment feature with regards to joining your traditional active directory domain.<\/p>\n\n\n\n The following link <\/a>provides you a step by step guide in how to perform the required steps to join your domain. So feel free to read through it. But wait!<\/strong><\/p>\n\n\n\n I’ve taken the opportunity to automate <\/strong>the necessary steps and put it in the following script. Note: Make sure to run it from a domain joined machine or directly on your domain controller.<\/em><\/strong><\/p>\n\n\n\n Download the script here<\/a>, or copy paste the scriptblock below. After running the script your Azure Storage Account will be joined to the domain, this is how it could look like.<\/p>\n\n\n\n Now that we have our storage account joined to the domain. We need to assign the right set of role based access controls on the Azure File Share level.<\/p>\n\n\n\n 3 built-in roles can be identified to set access to the Azure File Share:<\/p>\n\n\n\n The following script can assist you in setting the right set of permissions for a certain security principal. Note: The security principal must be entered in a UPN format (username@corp.something)<\/p>\n\n\n\n Download the script here<\/a>, or copy paste the scriptblock below. After running the script you will be able to mount the Azure File share in the context of the security principal. <\/p>\n\n\n\n In the previous section we’ve set the share level permissions, as with traditional file server installations or implementations, we would set an additional layer of security, called NTFS permissions.<\/p>\n\n\n\n By mounting the Azure File share together with storage access key you we are elevating our privileges, allowing us to set fine grained ACLs.<\/p>\n\n\n\n The following script will automatically mount the drive-letter you choose based on the Access Keys of your storage account<\/p>\n\n\n\n Download the script here <\/a>or copy the scriptblock below. <\/p>\n\n\n\n Next steps could be defined as the following<\/p>\n\n\n\n Feel free to comment or provide additional insights on the scripts and documentation provided. <\/p>\n","protected":false},"excerpt":{"rendered":" A couple of days ago, Microsoft announced the public preview of Windows Server Active Directory authentication \/ integration for Azure Files. Make sure to check-out the introduction video by Will Gries (Senior Program Manager) and Thomas Maurer (Senior Cloud Advocate) This is probably one of the most requested […]<\/p>\n","protected":false},"author":1,"featured_media":706,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":[],"categories":[31,30,20,32,23,34],"tags":[52,25,49,53,50,51],"yoast_head":"\n
This is probably one of the most requested feature releases since the ability to create file shares on Azure Storage.
In the recent past, Microsoft enabled Active Directory Authentication and setting ACLs coming from their Azure AD Domain Services solution.<\/p>\n\n\n\nLong story\nshort<\/h3>\n\n\n\n
<\/figure><\/div>\n\n\n\n
Now the long(er) story ?<\/h3>\n\n\n\n
1. Windows Server Active Directory needs to be synchronized with Azure Active Directory<\/strong><\/h4>\n\n\n\n
2. You need an Azure Storage account with an Azure File share which is NOT located in one of the following regions.<\/strong><\/h4>\n\n\n\n
! Run the following script if you like to create a new storage account<\/h6>\n\n\n\n
Powershell Script<\/a><\/h5>\n\n\n
\n########################\n#\n# Name: Azure Files Create Storage Account\n# Author: Yannick Dils\n# Version: v0.1\n#\n########################\n\nWrite-Host "Let's get started" -ForegroundColor Magenta\nSleep 3\n\n########################\n#\n# Install or import the required modules\n#\n########################\n\nstart-process powershell \u2013verb runAs -ArgumentList "Install-Module -Name Az.Accounts -RequiredVersion 1.6.4 -Force" -WindowStyle Hidden\nImport-Module Az.Accounts\nstart-process powershell \u2013verb runAs -ArgumentList "Install-Module -Name Az.Resources -RequiredVersion 1.11.0 -Force" -WindowStyle Hidden\nImport-Module Az.Resources\nstart-process powershell \u2013verb runAs -ArgumentList "Install-Module -Name Az.Storage -RequiredVersion 1.11.0 -Force" -WindowStyle Hidden\nImport-Module Az.Storage\n\n########################\n#\n# Create Naming Convention + Location and Name Variables\n#\n########################\n\nWrite-Host "Step 1 : Let's define some variables and naming conventions`n" -ForegroundColor Cyan\n\nWrite-Host "Enter a 3 letter word abbreviation for your customer or project (example: tuc, vdc) : " -ForegroundColor Yellow -NoNewline\n$Cus = Read-Host\nWrite-Host "Enter a 3 letter word abbreviation for your environment (example: hub, prd, tst, dev, acc) : " -ForegroundColor Yellow -NoNewline\n$Env = Read-host\n$FullLocation = "France Central"\n$NamingConv = "st" + "lrs" + $Cus + "frc" + $Env + "file"\n$SAFILE = $NamingConv\n$RGDATA = $Cus + "-hub-storage-rg"\nWrite-Host "Enter a name for your fileshare (example: fileserver, profiles,..) : " -ForegroundColor Yellow -NoNewline\n$FileShareName = Read-host\n\n\nWrite-Host "`nStep 2 : Based on the naming convention provided in the script, the following has been identitfied:`n" -ForegroundColor Cyan\nWrite-Host "Location : $FullLocation" -ForegroundColor Green\nWrite-Host "Storage Account Name : $SAFILE" -ForegroundColor Green\nWrite-Host "Fileshare Name : $FileShareName" -ForegroundColor Green\n\nWrite-Host "Resource Group Name : $RGDATA" -ForegroundColor Green\n\n\n########################\n#\n# Login to Az Account\n#\n########################\n\nWrite-Host "`nStep 3 : Before we continue, we need to log you into your Azure Account" -ForegroundColor Cyan\n\nLogin-AzAccount\n\n########################\n#\n# Select the Azure Subscription where you want to create your storage account\n#\n########################\n\n$Subscriptions = Get-AzSubscription\nWrite-Host "Step 4 : These are your available subscriptions`n" -ForegroundColor Cyan\nWrite-host $Subscriptions.Name -ForegroundColor Cyan -BackgroundColor Black\n\nWrite-Host "`nStep 5 : Enter the subscription name : " -ForegroundColor Yellow -NoNewline\n$SubscriptionName = Read-host\nSelect-AzSubscription -Subscription $SubscriptionName\n\n\n\n########################\n#\n# Verify if an existing resource group exists with the name in variable $RGDATa, create a new one if not\n#\n########################\n\n\n$RG = Get-AzResourceGroup -Name $RGDATA -ErrorAction SilentlyContinue\n\nIf ($RG)\n {\n Write-Host "Step 6 : A Resource Group already exists with the name $RGDATA, no need to create one" -ForegroundColor Cyan\n }\nElse\n {\n Write-Host "Step 6 : A Resource Group is created with the name $RGDATA" -ForegroundColor Cyan\n New-AzResourceGroup -Name $RGDATA -Location $FullLocation\n }\n\n########################\n#\n# Create a new Storage Account located in the $FullLocation region based on the input variables\n#\n########################\n\n$SA = Get-AzStorageAccount -ResourceGroupName $RGDATA -Name $SAFILE.ToLower() -ErrorAction SilentlyContinue\n$StorageShare = Get-AzStorageShare -Name $FileShareName -Context $sa.Context -ErrorAction SilentlyContinue\n\nIf ($SA)\n {\n Write-Host "Step 7 : A Storage Account already exists with the name $SAFILE, no need to create one" -ForegroundColor Cyan\n\n If ($StorageShare)\n {\n Write-Host "Step 8 : A File Share already exists with the name $FileShareName, no need to create one" -ForegroundColor Cyan\n }\n Else\n {\n Write-Host "Step 8 : A File Share is created with the name $FileShareName" -ForegroundColor Cyan\n New-AzStorageShare -Name $FileShareName -Context $SA.Context\n }\n\n\n\n\n }\nElse\n {\n Write-Host "Step 7 : A Storage Account is created with the name $SAFILE" -ForegroundColor Cyan\n New-AzStorageAccount -ResourceGroupName $RGDATA -Name $SAFILE.ToLower() -Kind StorageV2 -SkuName Standard_LRS -Location $FullLocation -AccessTier Hot\n Write-Host "Step 8 : A File Share is created with the name $FileShareName" -ForegroundColor Cyan\n $ctx = Get-AzStorageAccount -ResourceGroupName $RGDATa -Name $SAFILE\n New-AzStorageShare -Name $FileShareName -Context $ctx.Context\n\n }\n\nWrite-Host "End of script" -ForegroundColor Magenta\n\n\n########################\n#\n# End of script\n#\n########################\n\nSLeep 5\n<\/pre>\n\n\n
3. You need to join your Azure Storage account to the domain<\/strong><\/h4>\n\n\n\n
Powershell Script<\/a><\/h5>\n\n\n
\n########################\n#\n# Name: Azure Files Domain Join Script\n# Author: Yannick Dils\n# Version: v0.1\n#\n########################\n\nWrite-Host "Let's get started" -ForegroundColor Cyan\nSleep 3\n\n########################\n#\n# Install or import the required modules\n#\n########################\n\nstart-process powershell \u2013verb runAs -ArgumentList "Install-Module -Name Az.Accounts -RequiredVersion 1.6.4 -Force" -WindowStyle Hidden\nImport-Module Az.Accounts\nstart-process powershell \u2013verb runAs -ArgumentList "Install-Module -Name Az.Resources -RequiredVersion 1.11.0 -Force" -WindowStyle Hidden\nImport-Module Az.Resources\nstart-process powershell \u2013verb runAs -ArgumentList "Install-Module -Name Az.Storage -RequiredVersion 1.11.0 -Force" -WindowStyle Hidden\nImport-Module Az.Storage\nstart-process powershell \u2013verb runAs -ArgumentList "Install-Module -Name ActiveDirectory -Force" -WindowStyle Hidden\nImport-Module ActiveDirectory\n\n\n########################\n#\n# Change the execution policy to unblock importing AzFilesHybrid.psm1 module\n#\n########################\n\nSet-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Currentuser -Force -ErrorAction SilentlyContinue\n\n########################\n#\n# Download The AzFilesHybird powershell modules\n#\n########################\n\nWrite-Host "Step 1 : We will now download the Azure Files Hybrid powershell modules into a C:\\Temp directory" -ForegroundColor Cyan\n\n\n$DownloadLink = "https:\/\/github.com\/Azure-Samples\/azure-files-samples\/releases\/download\/AzFilesHybrid-0.1.0.0\/AzFilesHybrid.zip"\n$TempDir = "C:\\Temp"\n$Output = "C:\\Temp\\AzFilesHybrid.zip"\n$Path = Test-Path $TempDir\n\nIf ($Path -eq $true)\n {\n Write-Host "Step 2 : The C:\\Temp path already exists, no need to create one" -ForegroundColor Cyan\n }\nElse\n {\n Write-host "Step 2 : We are creating a temp directory C:\\Temp" -ForegroundColor Cyan\n $DontShow = mkdir $TempDir\n\n }\n\n\n(New-Object System.Net.WebClient).DownloadFile($DownloadLink, $output)\n\n########################\n#\n# Navigate to where AzFilesHybrid is unzipped and stored and run to copy the files into your path\n#\n########################\n\ncd $TempDir\nExpand-Archive -LiteralPath $Output -DestinationPath $TempDir -Force\n.\\CopyToPSPath.ps1 \n\n########################\n#\n# Import AzFilesHybrid module\n#\n########################\n\n\nImport-Module -name AzFilesHybrid\n\n\n########################\n#\n# Login with an Azure AD credential that has either storage account owner or contributer RBAC assignment\n#\n########################\n\nWrite-Host "Step 3 : Let's connect to our Azure Subscriptions" -ForegroundColor Cyan\nSleep 3\nConnect-AzAccount\n\n########################\n#\n# Select the Azure Subscription where your Storage Account is located\n#\n########################\n\n$Subscriptions = Get-AzSubscription\nWrite-Host "Step 4 : These are your available subscriptions" -ForegroundColor Cyan\nWrite-host $Subscriptions.Name -ForegroundColor Cyan -BackgroundColor Black\n\nWrite-Host "Step 5 : Enter the subscription name : " -ForegroundColor Yellow -NoNewline\n$SubscriptionName = Read-host\nSelect-AzSubscription -Subscription $SubscriptionName\n\n########################\n#\n# Retrieve your current Windows Server Active Directory Domain Details\n#\n########################\n\n\n$domaindetails = Get-ADDomain\n#Register the target storage account with your active directory environment under the target OU\n$Domain = $domaindetails.DNSRoot\n\n\n########################\n#\n# Retrieve your Resource Groups and Storage Accounts located in your Azure Subscription\n#\n########################\n\n#############\n#\n# Resource Groups\n#\n#############\n\n$ResourceGroups = Get-AzResourceGroup | Select ResourceGroupName\nWrite-Host "Step 6 : These are the available resource groups: " -ForegroundColor Cyan\nForeach ($RG in $ResourceGroups)\n {\n Write-Host $RG.ResourceGroupName -ForegroundColor Cyan -BackgroundColor Black\n }\nWrite-Host "Step 7 : Enter the resource group name, where your Azure Files storage account is located: " -ForegroundColor Yellow -NoNewline\n$ResourceGroup = Read-host \n\n#############\n#\n# Storage Accounts\n#\n#############\n\n\n$StorageAccounts = Get-AzStorageAccount -ResourceGroupName $ResourceGroup\n\nWrite-Host "Step 8 : These are the available storage accounts : " -ForegroundColor Cyan\n\nForeach ($SA in $StorageAccounts)\n {\n Write-Host $SA.StorageAccountName -ForegroundColor Cyan -BackgroundColor Black\n }\nWrite-Host "Step 9 : Enter the storage account name, where your Azure Files share is located: " -ForegroundColor Yellow -NoNewline\n$StorageAccount = Read-host\n\n########################\n#\n# Create or use an Organizational Unit where our Azure Files storage account will be located\n#\n########################\n$AzureFilesOUName = "AzureFiles"\n\nWrite-Host "Step 10 : We now want to join the Azure File Storage Accounts to the domain in an OU called $AzureFilesOUName" -ForegroundColor Cyan\n\n\n$OU = Get-ADOrganizationalUnit -Filter 'Name -like $AzureFilesOUName'\nIf ($OU)\n {Write-Host "Step 11 : The AzureFiles OU Already Exists, no need to create one" -ForegroundColor Cyan}\nElse\n {\n Write-Host "Step 11 : The OU needs to be created, we will now create a new OU called $AzureFilesOUName" -ForegroundColor Cyan\n $AzureFilesOU = New-ADOrganizationalUnit -Name $AzureFilesOUName\n }\n\n########################\n#\n# Join the storage account into the domain, located in the required organizational unit\n#\n########################\n\nJoin-AzStorageAccountForAuth -ResourceGroupName $ResourceGroup -StorageAccountName $StorageAccount -Domain $Domain -DomainAccountType ComputerAccount -OrganizationalUnitName "Servers"\n\n########################\n#\n# Verify Domain Join\n#\n########################\n\n$azurefiles = Get-AzStorageAccount -ResourceGroupName $ResourceGroup -Name $StorageAccount\n\n$ADService = $azurefiles.AzureFilesIdentityBasedAuth.DirectoryServiceOptions\n\nWrite-Host "Step 12 : Let us now verify if the directory service is ok" -ForegroundColor Cyan\nSleep 5\n\nIf ($ADService -eq "AD")\n {\n Write-host "Step 13 : All OK" -ForegroundColor Green\n }\nElse\n {\n Write-host "Step 13 : Something went wrong ;)" -ForegroundColor Red\n }\n\n\nWrite-Host "Step 14 : Let us now verify if the directory authentication is ok" -ForegroundColor Cyan\nSleep 5\n\n$ADInfo = $azurefiles.AzureFilesIdentityBasedAuth.ActiveDirectoryProperties\n\nIf ($ADInfo.DomainName -eq $Domain)\n {\n Write-host "Step 15 : All OK" -ForegroundColor Green\n }\nElse\n {\n Write-host "Step 15 : Something went wrong ;)" -ForegroundColor Red\n }\n\nWrite-host "End of script" -ForegroundColor Cyan\nSleep 5\n\n########################\n#\n# End of script\n#\n########################\n\n<\/pre>\n\n\n
4. Assign the required roles to your security principals.<\/strong><\/h4>\n\n\n\n
<\/figure><\/div>\n\n\n\n
Powershell Script<\/a><\/h5>\n\n\n
\n########################\n#\n# Name: Azure Files RBAC\n# Author: Yannick Dils\n# Version: v0.1\n#\n########################\n\n\nWrite-Host "Let's get started" -ForegroundColor Cyan\nSleep 3\n\n########################\n#\n# Set General Variables and Naming Conventions\n#\n########################\n\nWrite-Host "Step 1 : Let's define some variables and naming conventions" -ForegroundColor Cyan\n\nWrite-Host "Enter a 3 letter word abbreviation for your customer or project (example: tuc, vdc) : " -ForegroundColor Yellow -NoNewline\n$Cus = Read-Host\nWrite-Host "Enter a 3 letter word abbreviation for your environment (example: hub, prd, tst, dev, acc) : " -ForegroundColor Yellow -NoNewline\n$Env = Read-host\n$FullLocation = "France Central"\n$NamingConv = "st" + "lrs" + $Cus + "frc" + $Env + "file"\n$SAFILE = $NamingConv\n$RGDATA = $Cus + "-hub-storage-rg"\nWrite-Host "Enter a name for your fileshare (example: fileserver, profiles,..) : " -ForegroundColor Yellow -NoNewline\n$FileShareName = Read-host\n\n\n\n########################\n#\n# Set the names of the Azure Files Roles into Variables\n#\n########################\n\nWrite-Host "Step 2 : Let's store the Azure File Storage Roles into variables for later use" -ForegroundColor Cyan\n\n\n$Reader = "Storage File Data SMB Share Reader" # R permissions\n$Contributor = "Storage File Data SMB Share Contributor" # R W D permissions\n$ElevatedContributor ="Storage File Data SMB Share Elevated Contributor" # R W D M permissions\n\n########################\n#\n# Enter the specific group in UPN format and store them into variables\n#\n########################\n\nWrite-Host "Step 3 : Enter the security principal that needs to receive the required access controls (UPN format required):`n" -ForegroundColor Cyan\nWrite-Host "Read Group = Storage File Data SMB Share Reader # R permissions" -ForegroundColor Green\nWrite-Host "Contributor Group = Storage File Data SMB Share Contributor # R W D permissions" -ForegroundColor Green\nWrite-Host "ElevatedContributor = Storage File Data SMB Share Elevated Contributor # R W D M permissions`n" -ForegroundColor green\n\nWrite-Host "Enter the Reader Security Principal UPN Name : (Leave empty if not required) :" -ForegroundColor Yellow -NoNewline\n$ReadGroup = Read-Host\nWrite-Host "Enter the Contributor Security Principal UPN name : (Leave empty if not required) :" -ForegroundColor Yellow -NoNewline\n$ContributorGroup = Read-Host\nWrite-Host "Elevated Contributor Security Principal UPN name : (Leave empty if not required) :" -ForegroundColor Yellow -NoNewline\n$ElevatedContributorGroup = Read-host\n\n########################\n#\n# Set the scope onto our subscription and specific Azure File Share\n#\n########################\n\nWrite-Host "`nStep 4 : Let's set our subscription scope`n" -ForegroundColor Cyan\nLogin-AzAccount\n$Subscriptions = Get-AzSubscription\nWrite-Host "Step 5 : These are your available subscriptions`n" -ForegroundColor Cyan\nWrite-host $Subscriptions.Name -ForegroundColor Cyan -BackgroundColor Black\n\nWrite-Host "`nStep 6 : Enter the subscription name : " -ForegroundColor Yellow -NoNewline\n$SubscriptionName = Read-host\nSelect-AzSubscription -Subscription $SubscriptionName\n$Subscription = Get-AzSubscription -SubscriptionName $SubscriptionName\n\n$SubScriptionID = $Subscription.SubscriptionId\n\n\n$scope = "\/subscriptions\/$subscriptionID\/resourceGroups\/$RGDATA\/providers\/Microsoft.Storage\/storageAccounts\/$SAFILE\/fileServices\/default\/fileshares\/$fileShareName"\n\n########################\n#\n# Let's assign the role to the specified security principal and scope\n#\n########################\n\n##########\n#\n# Reader Group\n#\n##########\n\nIf($ReadGroup -eq "")\n {\n Write-Host "You haven't entered any Reader Group, we will skip this role assignment for now" -ForegroundColor Yellow\n }\nelse\n {\n Write-Host "We are now verifying the Reader Group role assignment for Security Principal $ReadGroup" -ForegroundColor Cyan\n $RoleAssignment = Get-AzRoleAssignment -SignInName $ReadGroup -RoleDefinitionName $Reader -Scope $scope -ErrorAction SilentlyContinue\n\n If ($RoleAssignment)\n {\n Write-host "The role assignment already exists, we don't need to add the specific assignment" -ForegroundColor Cyan\n }\n else\n {\n Write-Host "The role assignment is being created" -ForegroundColor Cyan\n New-AzRoleAssignment -SignInName $ReadGroup -RoleDefinitionName $Reader -Scope $scope\n }\n\n }\n\n\n\n\n##########\n#\n# Contributor Group\n#\n##########\n\n\nIf($ContributorGroup -eq "")\n {\n Write-Host "You haven't entered any Contributor Group, we will skip this role assignment for now" -ForegroundColor Yellow\n }\nelse\n {\n Write-Host "We are now verifying the Contributor Group role assignment for Security Principal $ContributorGroup" -ForegroundColor Cyan\n $RoleAssignment = Get-AzRoleAssignment -SignInName $ContributorGroup -RoleDefinitionName $Contributor -Scope $scope -ErrorAction SilentlyContinue\n\n If ($RoleAssignment)\n {\n Write-host "The role assignment already exists, we don't need to add the specific assignment" -ForegroundColor Cyan\n }\n else\n {\n Write-Host "The role assignment is being created" -ForegroundColor Cyan\n New-AzRoleAssignment -SignInName $ContributorGroup -RoleDefinitionName $Contributor -Scope $scope\n }\n\n }\n\n\n\n##########\n#\n# Elevated Contributor Group\n#\n##########\n\nIf($ElevatedContributorGroup -eq "")\n {\n Write-Host "You haven't entered any Elevated Contributor Group, we will skip this role assignment for now" -ForegroundColor Yellow\n }\nelse\n {\n Write-Host "We are now verifying the Elevated Contributor Group role assignment for Security Principal $ElevatedContributorGroup" -ForegroundColor Cyan\n $RoleAssignment = Get-AzRoleAssignment -SignInName $ElevatedContributorGroup -RoleDefinitionName $ElevatedContributor -Scope $scope -ErrorAction SilentlyContinue \n\n If ($RoleAssignment)\n {\n Write-host "The role assignment already exists, we don't need to add the specific assignment" -ForegroundColor Cyan\n }\n else\n {\n Write-Host "The role assignment is being created" -ForegroundColor Cyan\n New-AzRoleAssignment -SignInName $ElevatedContributorGroup -RoleDefinitionName $ElevatedContributor -Scope $scope\n }\n\n }\n\n\n #Get-AzRoleAssignment -scope $scope\n\n Write-Host "`nEnd of Script" -ForegroundColor Cyan \n\n Sleep 5\n<\/pre>\n\n\n
5. Mount the Azure File Share with elevated privileges and start configuring NTFS permissions.<\/strong><\/h4>\n\n\n\n
<\/figure>\n\n\n\n
Powershell Script<\/a><\/h5>\n\n\n
\n########################\n#\n# Name: Mount Azure File Share\n# Author: Yannick Dils\n# Version: v0.1\n#\n########################\n\nWrite-Host "Let's get started" -ForegroundColor Cyan\nSleep 3\n\n########################\n#\n# Create Naming Convention + Location and Name Variables\n#\n########################\n\n\nWrite-Host "Step 1 : Let's define some variables and naming conventions`n" -ForegroundColor Cyan\n\nWrite-Host "Enter a 3 letter word abbreviation for your customer or project (example: tuc, vdc) : " -ForegroundColor Yellow -NoNewline\n$Cus = Read-Host\nWrite-Host "Enter a 3 letter word abbreviation for your environment (example: hub, prd, tst, dev, acc) : " -ForegroundColor Yellow -NoNewline\n$Env = Read-host\n$FullLocation = "France Central"\n$NamingConv = "st" + "lrs" + $Cus + "frc" + $Env + "file"\n$SAFILE = $NamingConv\n$RGDATA = $Cus + "-hub-storage-rg"\nWrite-Host "Enter a name for your fileshare (example: fileserver, profiles,..) : " -ForegroundColor Yellow -NoNewline\n$FileShareName = Read-host\nWrite-Host "Enter a driveletter for your fileshare (example: F, G, P..) : " -ForegroundColor Yellow -NoNewline\n$DriveLetter = Read-Host\n\n\n########################\n#\n# Login with an Azure AD credential that has either storage account owner or contributer RBAC assignment\n#\n########################\n\nWrite-Host "Step 2 : Let's connect to our Azure Subscriptions" -ForegroundColor Cyan\nSleep 3\nConnect-AzAccount\n\n########################\n#\n# Select the Azure Subscription where your Storage Account is located\n#\n########################\n\n$Subscriptions = Get-AzSubscription\nWrite-Host "Step 3 : These are your available subscriptions" -ForegroundColor Cyan\nWrite-host $Subscriptions.Name -ForegroundColor Cyan -BackgroundColor Black\n\nWrite-Host "`nEnter the subscription name : " -ForegroundColor Yellow -NoNewline\n$SubscriptionName = Read-host\nSelect-AzSubscription -Subscription $SubscriptionName\n\n########################\n#\n# Retrieve the Storage Account Details and Access Tokens\n#\n########################\n\nWrite-Host "Step 4 : We are now retrieving the storage account details and access tokens" -ForegroundColor Cyan\n\n$storageAccount = Get-AzStorageAccount -ResourceGroupName $RGDATA -Name $SAFILE\n$storageAccountKeys = Get-AzStorageAccountKey -ResourceGroupName $RGDATA -Name $SAFILE\n\n########################\n#\n# Retrieve the FileShare Details\n#\n########################\n\nWrite-Host "Step 5 : We are now retrieving the file share details" -ForegroundColor Cyan\n\n\n$fileShare = Get-AzStorageShare -Context $storageAccount.Context | Where-Object { \n $_.Name -eq $fileShareName -and $_.IsSnapshot -eq $false\n}\n\nif ($fileShare -eq $null) {\n throw [System.Exception]::new("Azure file share not found")\n}\n\n########################\n#\n# Mount the Azure File Storage\n#\n########################\n\nWrite-Host "Step 6 : Your file share is being mounted" -ForegroundColor Cyan\n\n\n$password = ConvertTo-SecureString -String $storageAccountKeys[0].Value -AsPlainText -Force\n$credential = New-Object System.Management.Automation.PSCredential -ArgumentList "AZURE\\$($storageAccount.StorageAccountName)", $password\nNew-PSDrive -Name $DriveLetter -PSProvider FileSystem -Root "\\\\$($fileShare.StorageUri.PrimaryUri.Host)\\$($fileShare.Name)" -Credential $credential -Persist\n\nWrite-Host "Step 7 : Let's open up our file share in an explorer window" -ForegroundColor Cyan\n\n$path = $DriveLetter + ":\\" \nInvoke-Item $path\n\nWrite-Host "`nEnd of script" -ForegroundColor Cyan\nSleep 5\n\n########################\n#\n# End of script\n#\n########################\n<\/pre>\n\n\n
6. Next Steps<\/strong><\/h4>\n\n\n\n