The Developer Space

Developer's Cafe

  • Cloud
  • Database
  • Open Source
  • Programming
  • Web Dev
  • Mobile
  • Security
  • QuickRef
  • Home
  • Cloud
  • Granting write access to ASP.NET apps hosted on AWS Beanstalk

Granting write access to ASP.NET apps hosted on AWS Beanstalk

Shameel Ahmed - ASP.NET, AWS, Cloud, CodeProject, Web Development
April 28, 2017September 21, 2019 No Comments
ebextensions folder
6 0
Read Time2 Minute, 42 Second

Introduction

This article describes a simple and elegant way to allow write access to ASP.NET apps to the App_Data folder. This is required for applications to work properly when deployed in AWS Beanstalk.

The Problem

ASP.NET applications and websites usually write user content and files in the App_Data folder. Examples of such files could be SQL Server compact (.mdf), Xml files, text files, etc. Therefore, when an ASP.NET site is hosted, the AppPool under which the application or website runs must have write permissions on the App_Data folder.

When an ASP.NET application is hosted on AWS Beanstalk, we do not have direct access to the file system of the application. But AWS provides a way to grant permission on specific folders through config files.

The Solution

The solution is to include a YAML file to your Visual Studio project that instructs the deployment tool to grant the necessary access permissions.

Step 1

Add a top-level folder to your Visual Studio project and name it ‘.ebextensions’

Step 2

Add a file named <ApplicationName>.config where <ApplicationName> is the name of your AWS application

Step 3

The config file can either contain YAML script or Json. AWS first tries to parse the file using YAML parser, if the parsing fails, then it tries to parse it using Json parser. If both parsing fails, the deployment is aborted and you can see the error in the log in your Beanstalk application console.

Step 4

Add the following YAML code to the config file:

If your project is a web site hosted on Default Web Site/, use this script

container_commands:
  01storage_permissions:
    command: "icacls C:\\inetpub\\wwwroot\\App_Data /grant DefaultAppPool:(OI)(CI)F"

Or if your Visual Studio project is a web project hosted under a Virtual Directory, use this script

container_commands:
  01storage_permissions:
    command: "icacls C:\\inetpub\\wwwroot\\[MyApp]\\App_Data /grant DefaultAppPool:(OI)(CI)F"

Replace [MyApp] with your Visual Studio Project name (not Solution name)

When this project is deployed to AWS Beanstalk using Visual Studio Tools for AWS add-in, this script will be executed and Full permission will be granted on the folder for DefaultAppPool. If you’re using a custom AppPool, use the custom AppPool name instead of DefaultAppPool in the script.

A detailed description of the icacls utility can be found here.

Share

Facebook
Twitter
LinkedIn
Email

Post navigation

Windows Phone 8.1 Review
Browser Selector – A simple windows app to associate different urls to different browsers

Related Articles

Migrate your SQL Server Workloads to PostgreSQL: Quick Reference: Second Edition

Book: Migrate your SQL Server Workloads to PostgreSQL: Quick Reference – Second Edition

Shameel Ahmed
October 18, 2022October 22, 2022 1 Comment

Cross Region Lambda invocation in AWS

Shameel Ahmed
February 27, 2022February 27, 2022 No Comments
Migrating your SQL Server Workloads to PostgreSQL

Book: Migrating your SQL Server Workloads to PostgreSQL

Shameel Ahmed
May 5, 2020October 22, 2022 No Comments

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%
(Add your review)

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

.NET Architecture Artificial Intelligence ASP.NET AWS Azure Books C# Career Cloud CodeProject Conversational Bots Database Data Security Facade IDEs Java Mobile MongoDB MySQL Open Source Patterns PostgreSQL Programming Python Redis Security SQL Server Tools Uncategorized Web Development Windows Phone

Recent Posts

  • Developer to Architect Series (Red Hat Enable Architect) January 16, 2023
  • Can ChatGPT replace Google Search? January 11, 2023
  • Learn Python with ChatGPT December 26, 2022
  • Book: Migrate your SQL Server Workloads to PostgreSQL: Quick Reference – Second Edition October 18, 2022
  • Increase Visual Studio Code Terminal Buffer Size July 14, 2022

Archives

  • January 2023 (2)
  • December 2022 (1)
  • October 2022 (1)
  • July 2022 (2)
  • February 2022 (1)
  • November 2021 (1)
  • July 2021 (1)
  • June 2021 (1)
  • September 2020 (1)
  • May 2020 (2)
  • April 2020 (1)
  • October 2019 (1)
  • September 2019 (4)
  • July 2019 (2)
  • May 2018 (1)
  • September 2017 (1)
  • April 2017 (1)
  • April 2014 (1)
  • August 2011 (1)
  • June 2009 (1)
Copyright 2022. The Developer Space | Theme: OMag by LilyTurf Themes
  • DbStudio
  • Re:Link
  • shameel.net
  • Privacy Policy
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie settingsACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are as essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
SAVE & ACCEPT