Access to Azure File Storage via VNet - c#

I faced with follow problem hope I can find the way for solving with your help.
I created follow Azure resources:
WebApp Service (Asp.Net Core web application)
FileStorage
VirtualNetwork
All resources created in one resources group. I trying to upload file from my WebApp to File storage via VNet (I need to secure storage so it must be unaccessable from outside internet).
Virtual Network have subnet, wich have setup a Microsoft.Storage - Service endpoints. This sub net is included In Storage firewall settings.
For work with Azure storage I use Microsoft.WindowsAzure.Storage package.
When I trying to get access to storage from webapp I get 403 error.
For access I use 'primary file service endpoint' - https://myaccount.file.core.windows.net/
What I have missed ?
Thnx for any advice !

Azure File shares can’t be accessed from Azure App Service web apps. Refer this feedback item where the feature was declined.

Related

ASP.NET Core 5 API write files on Azure Web App disk space

I do have an ASP.NET Core 5 Web API project which is currently hosted as an Azure Web App on a Windows App Service plan. Since I have a couple of gigabytes of storage associated with the App Service plan, I want to use 10 GB for an image cache where I store images generated from the API.
Here is some context:
I don't want to use Azure Storage / Blob Storage for this to avoid unnecessary traffic costs and delays. Some images are generated from multiple layers of other images (let's call them intermediate images) and I cache everything.
My caching solution works fine locally, but currently not on Azure.
I want to use 'Remove additional files at destination' when publishing a new version of my API.
The cache will be cleared/invalidated via an API call, not on deployment or app restart.
As I've said, the caching works fine if I run at locally on IIS Express. As far as I know, the Windows App Service plan uses Kestrel for hosting. I'm looking for a storage path within the Azure Web App, where I can create and delete directories + create/read/delete files.
Since the App Service Plan is B1, the App Service plan is running on a dedicated Azure VM, according to the docs: https://learn.microsoft.com/en-us/azure/app-service/overview-hosting-plans
From https://learn.microsoft.com/en-us/azure/app-service/operating-system-functionality, I've learned that there is a C drive and a D drive as well.
From my web app, I can select Development Tools -> Advances Tools -> Go to see Kudu. When I click on Environment in Kudu, I can see some absolute paths that I've tried to write to without success. I've also tried to access
Environment.GetEnvironmentVariable("HOME")
IWebHostEnvironment.WebRootPath
IWebHostEnvironment.ContentRootPath
"D:\home\site\wwwroot"
"D:\home\"
without success as well.
I also tried to add a virtual directory (since I want to store images in another directory to be able to use the 'remove additional files on destination' option). I also connected via FTP to /site/wwwroot/ where I can see my deployed application.
In the past, I was able to read files from a virtual directory from an ASP.NET Webforms application, but with this ASP.NET Core 5 API project, I didn't have any success mapping relative paths to absolute paths.
My main question is: What absolute path to I need to use in my API project to have create/delete directory permissions and create/read/delete file permission into my Azure Web App?
Okay, I've figured it out. I had some fatal errors when starting the application. It seems that they were related to ApplicationInsights. I removed it completly from the Azure Web Portal and now everything works.
The following path works as a base path D:\\home\\

How can I expose my Azure Table storage data as JSON?

I am new to Azure and trying to get the data from Azure table storage. I am able to read it using c# code and do all CRUD operations. But I am looking for built in REST API from azure storage? Is it available?
Below article says that we need to write our own service and deploy.
https://blog.kloud.com.au/2016/06/09/using-microsoft-azure-table-service-rest-api-to-collect-data-samples
But this require me to have IIS ?? or do I have to write app service in c#??
I want JSON because I want to read it from android app but I do not want to use azure android SDK. I want pure REST API
This article http://chrisrisner.com/Mobile-Services-and-Windows-Azure-Storage is close but it's recommending me create SQL Azure database!! so I am confused.
Based on your requirement, I would recommend you go Shared Access Signature (SAS) route. In short, a SAS is a time-limited/permission-based access to your Azure Storage resources. This removes the need for you to store the storage access key in your application as it poses a major security risk and some other issues.
To read more about SAS, please see this link: https://azure.microsoft.com/en-in/documentation/articles/storage-dotnet-shared-access-signature-part-1. This should give you some idea about what is possible with SAS.
Here's how it would work. There will be a server component which will know about the account key. Your app would request this server component to generate and return the SAS URL. It is recommended that you only grant the necessary permissions and only for the required duration in the SAS.
Once your app has the SAS URL, they can simply make HTTP requests directly to Azure Storage by using this SAS URL and get the data back directly from Azure Tables in JSON format. For example, if you want to fetch entities from a table you would make Query Entities REST API call: https://msdn.microsoft.com/en-us/library/azure/dd179421.aspx.
To learn more about SAS, please see this link as well: https://msdn.microsoft.com/en-us/library/azure/ee395415.aspx.
I do not want to store storage key inside android app.
This app is just showing the temperature from a azure storage which is real time pushed by event hub from device to table storage
Regardless your requirement is simply, and it is correct that we don't recommend to expose your storage key in clients. However, to provide table storage entities to your clients, we still need a backend server.
If you have an Azure Mobile Apps server as a backend server for your devices, you can directly integrate Azure Storage SDK in custom APIs to provide table storage entities for your devices. Refer to https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-dotnet-backend-how-to-use-server-sdk/#how-to-define-a-custom-api-controller for more.
If you don't have an Azure Mobile Apps, you can leverage Auzre Function Apps for you simple requirement, whose environment has automatically added the assembly Microsoft.WindowsAzure.Storage, please refer to https://azure.microsoft.com/en-us/documentation/articles/functions-reference-csharp/ for more.

How can I use "Azure File Storage" with Web App Service?

I have been struggling to find some resources that help explain, how we use the File Storage with Web App Service.
There are ways to use it with the old Web Roles, Check here (Using the Azure File Service in your Cloud Services (Web and Worker Roles)).
However, there is NO OnStart() methods in "Azure Web Service".
If you're looking for mapping a drive to your Azure File Service share in your Web App using SMB protocol, then I don't think you can do as of today.
What you could do is make use of Azure File Service REST API and manipulate shares and files that way. You don't have to actually use the REST API per se; you can simply use the latest version of .Net Storage Client library which is a wrapper over REST API.
Please see this link for more details on how to use this using Storage Client library: https://azure.microsoft.com/en-in/documentation/articles/storage-dotnet-how-to-use-files/.
Yes, you can. In Linux Web Apps and Windows Containers Web Apps only.
In the Web App, under Application Settings you will find Mount storage (Preview) section where you can mount Storage account. Works like a charm.

Parsing html files on Azure

I have code that parses 100 to 200 html webpages using HtmlAgilityPack every hour. I am collecting the parsed data and I am making an xml file which would then be consumed by users.
Now I want to move this code to Azure. Would it be possible to parse websites on Windows azure? If so: what kind of service provided by Azure should I use?
I am not familiar with Azure. Any hints would be appreciated. Thanks.
Azure offers you a couple of solutions:
IaaS
IaaS or Infrastructure as a Service. This means that you get the infrastructure from Azure and that you can host your own virtual machine on it. This does require you to maintain the server yourself but you get full flexibility.
PaaS or Platform as a Service. This not only gives you a VM to run your code on but also an operating system that is automatically maintained for you. This is what Azure is really about and what you should aim for.
When creating a PaaS application you can choose for a regular website or for a cloud service. A cloud service contains roles, web roles and worker roles. Web roles are regular IIS hosted websites. Worker roles are the Azure equivalent of a Windows service.
In your case I would look at worker roles. They can run continually and are ideal for exeucting scheduled operations. From your worker role you can access Azure Blob storage to store the XML files that you create. Those files can be exposed to external users in a secure way.
Windows Azure is a hosting environment. According to what kind of project you created, you may be looking for a Cloud Service, where you can just host any code you've written.

Deploy a web role on Azure

Below is the task i have to complete in a few weeks, my question is does anyone know of any tutorials or books which will be of use to me? I also only have little knowledge of C#.
You will design the relevant code in ASP.NET and C# so that you can
deploy a web role on Azure that can:
a) read in a zip file from input on the web page
b) uncompress the zip file which will have an executable, an
arbitrary list of arguments and data files
c) run the executable with the arguments (and hence read in the
data files).
d) store the output logs for access later.
You will test this by running a piece of code that reads in a set of
arguments which correspond to test files.
The executable will then read in the text files and then print them
out.
You will also have to design an appropriate UML to explain how the
different classes you have written interact.
You can deploy your service/role to Azure using Service Management API. Write a module which does the deployment and call this in your web.
Check these links that may help you.
Deploying An Azure Application
Publish Azure WebRole using Installer (like WIX)
About the Service Management API
The Windows Azure Accelerator for Web Roles makes it quick and easy
for you to deploy one or more websites across multiple Web Role
instances using Web Deploy. The accelerator includes a Visual Studio
project template that creates a Windows Azure web role to host one or
more websites.
Azure Tutorial; Be in cloud (Part 3) [Web Role]
Windows Azure and SQL Azure Tutorials - Tutorial 1: Using Windows Azure Web Role and Windows Azure Table Service
Check Azure in Action Book and it's content.
Hope these help you to get an idea that you want to implement.
That's hard homework: Upload a zip file to a cloud based server and run the .exe. Interesting...
Anyway, the Azure SDK is a great place to start. Also scan through Smarx's Cloud Cover shows. They cover pretty much everything.

Categories