By default the ASP.NET temporary folder size in a Windows Azure web role is limited to 100 MB. This is sufficient for the vast majority of applications, but some applications may require more storage space for temporary files. In particular this will happen for very large applications which generate a lot of dynamically generated code, or applications which use controls that make use of the temporary folder such as the standard FileUpload control. If you are encountering the problem of running out of temporary folder space you will get error messages such as OutOfMemoryException or ‘There is not enough space on the disk.’.
In order to change the size of the temp folder you need to create a new folder by defining a LocalStorage resource in your service definition file, then on role startup modify the website configuration to point the system.web/Compilation tempDirectory property to point to this folder.
<WebRole name="WebRole1" >
<Runtime executionContext="elevated" />
<Binding name="Endpoint1" endpointName="Endpoint1" />
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
<LocalStorage name="AspNetTemp1GB" sizeInMB="1000" />
<LocalStorage name="FileUploadFolder" sizeInMB="1000" />
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" Text="Upload" runat="server" OnClick="Button1_OnClick" />
protected void Button1_OnClick(object sender, EventArgs e)
Microsoft.WindowsAzure.ServiceRuntime.LocalResource FileUploadFolder = Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetLocalResource("FileUploadFolder");
public override bool OnStart()
// Get the location of the AspNetTemp1GB resource
Microsoft.WindowsAzure.ServiceRuntime.LocalResource aspNetTempFolder = Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetLocalResource("AspNetTemp1GB");
//Instantiate the IIS ServerManager
ServerManager iisManager = new ServerManager();
// Get the website. Note that "_Web" is the name of the site in the ServiceDefinition.csdef, so make sure you change this code if you change the site name in the .csdef
Application app = iisManager.Sites[RoleEnvironment.CurrentRoleInstance.Id + "_Web"].Applications;
// Get the web.config for the site
Configuration webHostConfig = app.GetWebConfiguration();
// Get a reference to the system.web/compilation element
ConfigurationSection compilationConfiguration = webHostConfig.GetSection("system.web/compilation");
// Set the tempDirectory property to the AspNetTemp1GB folder
compilationConfiguration.Attributes["tempDirectory"].Value = aspNetTempFolder.RootPath;
// Commit the changes
<!-- maxAllowedContentLength = 1 GB -->
<requestLimits maxAllowedContentLength="1073741824" />
<!-- maxRequestLength = 1 GB -->
<httpRuntime maxRequestLength="1048576" />
For more information about the ASP.NET Temporary Folder see http://msdn.microsoft.com/en-us/magazine/cc163496.aspx.
Is it necessary to TEMP folder after creating small tmp files (Path.GetTempFileName()) for a while?
Joey, can you clarify your question? If you create lots of small temp files in the TEMP folder, then yes, eventually you will run out of space. But for normal temp files that you are creating in code, you should really be using a LocalResource storage location rather than the TEMP folder.
thanks for your great article about the 100mb limitation!
it really helped me with my data intensive azure worker role problem :)
Am using windows azure custom mobile service, how can i increase the size
I am running a php application azure,currently i cannot upload files above 25 MB Size its getting timedout,i have changed all required settings to higher using .user.ini file,the changes are showing in phpinfo page as well still no sucess
upload_max_filesize = 950M
post_max_size = 900M
max_execution_time = 1200
max_input_time = 1200
memory_limit = 512M
max_file_uploads = 100
these are my values i am using,is the issue is related to any with the temporary folder,i even tried to change upload_tmp_dir value to another path but it didn't worked out,please help me
anoop try reading this article. it worked for me in azure with php file uploads.