4

We have deployed ASP.Net Core app on AWS EBS and have problem with writing files on it.

Access to the path C:\inetpub\AspNetCoreWebApps\app\App_Data\file.txt is denied

I added .ebextensions\[app_name].config but it did nothing

{
    "container_commands": {
        "01": {
            "command": "icacls \"C:/inetpub/AspNetCoreWebApps/app/App_Data\" /grant DefaultAppPool:(OI)(CI)"
        }
    }
}

I know that this is permission problem because when I RDP to machine and changed permission manually it solved problem. I would like to it during deploy using .ebextensions\[app_name].config

BLuM
  • 657
  • 5
  • 28
  • the ebextension file is yaml - make sure it is not tab delimited and is encoded in UTF-8. Also I'm assuming your extension file is not literally called [app_name].config. – Avner Mar 14 '17 at 05:41
  • Name off app is this same like here https://i.imgur.com/kEOGvCa.png also this same like in `aws-beanstalk-config.txt` => `Application.Name` – BLuM Mar 14 '17 at 06:41
  • just call it init.config and check the spacing and encoding. – Avner Mar 14 '17 at 10:30
  • 1
    `.ebextensions\[app_name].config` run before deploy and during deploy folder was recreated - that why it was not working. I fixed it by adding `postInstall` Power Shell script into `aws-windows-deployment-manifest.json` – BLuM Mar 15 '17 at 15:06
  • I cannot create that config file as, it takes it as xml file and I can not put json/yaml content inside it. – Dave Apr 21 '21 at 10:43

1 Answers1

5

.ebextensions\[app_name].config run before deploy and during deploy folder was recreated - that why it was not working. I fixed it by adding postInstall Power Shell script into aws-windows-deployment-manifest.json:

"scripts": {
      "postInstall": {
        "file": "SetupScripts/PostInstallSetup.ps1"
      }
# # PostInstallSetup.ps1 #
$SharePath = "C:\inetpub\AspNetCoreWebApps\app\App_Data"
$Acl = Get-ACL $SharePath
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("DefaultAppPool","full","ContainerInherit,Objectinherit","none","Allow")
$Acl.AddAccessRule($AccessRule)
Set-Acl $SharePath $Acl
BLuM
  • 657
  • 5
  • 28
  • Can you share the content of SetupScripts/PostInstallSetup.ps1? – Velimir Feb 06 '18 at 13:16
  • 1
    `# # PostInstallSetup.ps1 # $sharepath = "C:\inetpub\AspNetCoreWebApps\app\App_Data" $Acl = Get-ACL $SharePath $AccessRule= New-Object System.Security.AccessControl.FileSystemAccessRule("DefaultAppPool","full","ContainerInherit,Objectinherit","none","Allow") $Acl.AddAccessRule($AccessRule) Set-Acl $SharePath $Acl` – BLuM Feb 13 '18 at 14:03