An Azure service that offers file shares in the cloud.
HIi @ Monit Sharma,
Welcome to Microsoft Q&A Platform.
The Custom Script Extension (CSE) runs under the LocalSystem account before any domain or Azure AD authentication is in place, so it can’t authenticate to your Azure Files share to create folders or set NTFS ACLs. Here are a few alternate approaches you can try:
Post-domain-join script execution
- Join the VM to Azure AD DS, Microsoft Entra DS or your on-prem AD first.
- Use the Run Command extension or a Task Scheduler job (running as a domain account) to invoke your folder-creation PowerShell after the VM completes domain join.
- Mount the Azure Files share with your domain credentials and call Set-Acl in that context to create folders and set ACL inheritance.
- Use the Run Command extension or a Task Scheduler job (running as a domain account) to invoke your folder-creation PowerShell after the VM completes domain join.
Use an Azure AD–based identity (managed identity + RBAC)
- Enable identity-based auth on your file share and assign your VM’s system-assigned (or user-assigned) managed identity the “Storage File Data SMB Share Contributor” (to create directories) and “Storage File Data SMB Admin” (to manage ACLs) roles.
- Mount the share using Azure AD credentials (
-o anon,username=<>) so Windows uses the VM’s managed identity under the hood.- Run your Custom Script Extension or Run Command PowerShell commands under that context to create folders and call Set-Acl.
You can also use the Azure Automation runbooks with a managed identity to perform post-provisioning steps.
Note: Please make sure to assign the Virtual Machine Administrator Login role to the VM identity or user if you are running it from CSE. Alternatively, you can use an Automation Runbook and assign the same role to the Automation Identity. This role has local administrator permissions.
Ref: Use the Azure portal to manage ACLs in Azure Data Lake Storage
If the above steps did not help resolve your issue, please feel free to share the details in a private message so we can proceed with further troubleshooting over a Teams call. I am happy to connect with you on Teams to investigate and resolve the issue.
Please
and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.