The Developer Space

All things Developer

  • 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

Migrating your SQL Server Workloads to PostgreSQL

Book: Migrating your SQL Server Workloads to PostgreSQL

Shameel Ahmed
May 5, 2020May 26, 2020 No Comments

Minimize Non-Critical Database Workload costs in AWS

Shameel Ahmed
April 23, 2020April 24, 2020 4 Comments
.NET Core Logo

New Features and Enhancements in .NET Core 3.0

Shameel Ahmed
September 25, 2019October 8, 2019 1 Comment

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 ASP.NET AWS Azure Books C# Cloud CodeProject Database Data Security Facade Java Mobile Open Source Patterns PostgreSQL Programming Security SQL Server Tools Uncategorized Web Development Windows Phone

Recent Posts

  • Book Review: Dealing with Difficult People (HBR Emotional Intelligence Series) September 14, 2020
  • MYSWP – Book Links May 25, 2020
  • Book: Migrating your SQL Server Workloads to PostgreSQL May 5, 2020
  • Minimize Non-Critical Database Workload costs in AWS April 23, 2020
  • C# 8 New Features October 8, 2019

Archives

  • 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 2020. The Developer Space | Theme: OMag by LilyTurf Themes
  • DbStudio
  • shameel.net
  • Privacy Policy
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. 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