I have deployed a simple Web Site on Windows Azure as a Web App.
Using ASP.NET, whenever a user clicks on a button, a file is created as /hidden/test.txt. I want the directory, and the file, to be hidden and protected from any user accessing the website.
Currently, if you type www.sitename.com/hidden/test.txt on your browser you can access and view the content of the file.
How can I avoid this?
In Asp net App_Data folder is very secured so you can store your file in App_Data folder which could be use by the application but no any user can access from out side on url.("App_Data" is listed there as a restricted folder)
But on Azure Best practice is to store any file on Azure Storage Blob.
Related Link
https://azure.microsoft.com/en-in/documentation/articles/storage-dotnet-how-to-use-blobs/
Related
I'm managing small web app, deploying with (always) FTP. My teammate requested me to upload a folder including small teaser website. As usual routine, I opened the Azure Web App Deployment Center FTP dashboard and copied server address and credentials and pasted them into FileZilla(latest version). Login went well and I could see file list and folders. However, when I tried to upload files, remove existing files, all of the writing attempts failed with 550 Access is denied error. What could be the cause of this?
On the other hands, I could remove existing files on KUDU debug console.
I check the ftp link the deployment center provide, looks like the portal provides a read-only ftp link. So go to your web app, click Get publish profile, choose the publishUrl under tag profileName=<yourwebname-FTP>.
I have 2 different application deployed on Azure. First application of type webapi is used to upload files to the directory /doc/uploadedfiles of second application which is type webapp.
How to access basepath of second application from first application so that I can upload files to the /doc/uploadedfiles which is inside directory of second application.
You cannot. App services don't have access to different app's directories, and you shouldn't really store any files there.
You should save those documents on Blob Storage, so you'll be able to access them from any application.
I would like to create a simple static web site on Azure Web Apps. I don't want any VS or PowerShell so I have just connected my Azure Web App to my OneDrive account. I just want to edit my local files and see them on site.
I have created new web app, connected it to my OneDrive account and this step was fine, it created apps/Azure Web Apps/""app name"" folder in my OneDrive so I have placed some html/css files there. Web App was synchronized; however, I could not open any html file (404 could not get resource index.html).
I FTP-ed site and I have found that there is a following element in my Web.Config file:
<rule name="StaticContent">
<action url="public{REQUEST_URI}" type="Rewrite"/>
</rule>
Ok, so by default it assumes that static content will be in "public" folder so I have created "public" folder in my OneDrive and moved html file there. I have opened html file on my site url via browser and it was shown successfully!!!
Now, I have copied some other html/css files in subfolders of my "public" folder, but I cannot open them. Http requests to ""site""/somefolder/file.html ""site""/somefolder/file.css returns 404.
It seems that StaticContent rule do not matches subfolders.
I can continue hacking this and modifying iisnode rewrite rules, but am I missing something?
I just want simple static site connected to my OneDrive or Dropbox account, no VS, no power shell, no customization. Is it possible that this is a minefield if you are using the simple use case? Is there some tutorial or setting that I have not found?
It's actually a lot simpler than what you tried.
As CSharpRocks already suggested in a comment, you could place static HTML files and resource files into the root folder. However, you did say that you want to use your OneDrive account.
The trick is to identify the source location on your OneDrive account, after you set it up on Azure. It looks like you already tried that initially, but it appears that you also moved the files to a different "public" location.
Just to clarify, here are the steps that I performed.
In your Web App settings blade, click Continuous Deployment to select OneDrive, authenticate and choose the name, e.g. schtml5.
In your OneDrive account, find the source location, e.g. /Apps/Azure Web Apps/schtml5/
Place your static files into the above OneDrive location.
Since you already have continuous deployment set up (from Step 1), your website should be updated automatically every time that OneDrive folder (from Step 2) is updated. Make sure you choose to replace files when uploading any newer versions of files that already exist.
But you also mentioned that you have a Web.config file. Since you only have static files, you don't need this configuration file. Delete the Web.config file in Azure. You could use FTP to access your "/site/wwwroot" folder to delete the file. Make sure that you don't include the config file in OneDrive.
Hope that helps! :-)
Screenshots of my Azure portal and OneDrive below:
In MS Build 2020 Microsoft announced the support for hosting Static Web Apps which allows you to build JavaScript web applications that automatically publish from changes made in GitHub.
This new option is ideal for static site generators such as Hugo,
Jekyll and Hexo or for developers who use frameworks like
Angular, Vue and React and seek a simple interface to deploy
the cloud resources needed for a single-page application.
Here is an example to get started.
In a project we are working on we download a file (daily) from the web, that we then use in our code. The web app runs on an IIS server. Where would be the ideal location to download this file to? For development purposes we used "c:/temp/". Is the App_data folder used for things like this?
There is no ideal location.
The only thing that you have to take into account is that the Application Pool user defined in IIS has the necessary permissions on the chosen folder.
The easiest way to do it is to include it in a folder inside the web site directory. But this has a drawback: if you redeploy the web site code, you must take care not to delete that folder. So I usually prefer a folder outside the web site directory.
If you have an ad-hoc user in the app pool, giving the necessary permissions to that folder is done as usual. If it's the default user, then you have to do it in an special way, please, see this: How to assign permissions to ApplicationPoolIdentity account This link basically shows that you have to give permissions to a user whose name is: IIS APPPOOL\{app pool name}, for example IIS APPPOOL\DefaultAppPool. You must type it, as it doesn't appear in any search or listing of users (because it's an special user which is created dynamically when the application pool starts).
We have an application that we would like to migrate to Azure.There is a requirement in which a virtual temporary folder is created if not exist and a dynamic html page is to be created based on some user input which has been done in asp.net previously.How this can be achieved in azure web role.
I tried this requirement by adding a folder name called "Preview" and generated the html file under the preview folder.This works fine in the development machine(local). But it is throwing an exception in the live environment like
Directory Not found Exception (E:\siteroot\0\preview\previewbasic.htm).
I would like to preview the html page which was created dynamically in the preview folder if we specify the url in the browser as
[siteurl].cloudapp.net/preview/preview.htm.
My question is
1.Can we create a dynamic folder called "preview" in azure web role.
2.Can we generate a html file say(preview.htm) under this folder in web role.
3.Can this file be accessed as [siteurl].cloudapp.net/preview/preview.htm
I hope the question is somewhat clear now.
Any help would be much appreciated.
The local file system is not advised for Web Roles due to the fact that the storage is not guaranteed to be persistent -- if the web role is created using another VM then the files created in another instance will not be available. Therefore, you are better off using Azure Blob Storage. Files created via Blob Storage would be available among all instances of the Web Role.
Answers to your questions:
Create the container in Azure Blob Storage
Yes you could create the html and save it to the container created
You could make the URI for this blob public and then access it via your custom URL -- you'd have to create a CNAME for the storage container first.
Here is a good resource on how to use Blob Storage from .NET:
http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/