Deploy a web role on Azure - c#

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.

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\\

Where do I store media in an Azure Web App with C# ASP.NET

I am creating a C# ASP.NET app (using Visual Studio), which I'm hosting on Microsoft Azure. Currently, I have a folder in the solution named "Content", in which I store some media. For example, there a logo that is placed on the website.
The purpose of the web app is to generate a document that a user can download after entering some data. To generate this document, I also need to use some media (mainly images). There can be quite a lot of such images!
Where should I store these images? I currently have them in this "Content" folder as well (in seperate sub folders for each user), but I noticed on Azure there is also a tab called "Storage". I have tried to use this service for a bit, but I don't really understand its purpose. Would it be advisable to use this for storing the media, and then retrieving them with the web app when necessary, or should I leave them on the web app server? What is considered Good Practice?
Thanks in advance for any help
As a starting point, using Blob storage (see Azure Storage Documentation) would be significantly better than file storage on a single webserver - its cheaper and more scalable (pricing tiers for Application server storage will be expensive, you'd have have to duplicate files or have a multi-server directory in a load-balanced environment). The basic design is the application will use an SDK to retrieve the bits and then stream it back to the web browser or other client.
If you anticipate many users downloading the same file, and network performance matters, consider using a Content Delivery Network
You should store it in an Azure Storage Account and reference it using the SDK, after generating the document, you can use Shared Access Signature to give the user access and you can limit the access to read or write for a specific time.
If you will generate videos then you can serve it through Azure Media Services

Is it possible to deploy 2 separate MVC apps into one Azure Web App?

It's been incredible exhausting for me, after passing a week to deploy MVCForum (Source Code) to my Azure Web App. I've read that it was possible if you selected a different path when publishing, something that I did. But when I tried running, my main app and the MVC Forum were conflicting between them.
I'd like to use Azure's Web Apps instead of Azure's Cloud Services because of the simplicity and the possibility of only uploading the files that have changed. I have seen that it is possible to upload Web Api and MVC in that fashion, but I have not found an example that sends 2 different MVC apps into a same Web App.
Is it possible to do it with 2 different MVC apps? (Note: Areas are not an option, since the MVC Forum Source Code resides on a completely different solution)
Thanks!
Given your comment that you are trying to work with separate deployments:
A Web App under the same name (e.g. myapp.azurewebsites.net) is going to be managed by a single deployment. That is, if you have two github repo's (or two dropbox folders, or two of anything) and try to push up new content from deployment B, you'll effectively wipe out deployment A.
You can certainly have multi-path apps running in the same deployment, but they'd need to be part of a single distribution (e.g. single github repo). Otherwise, you'd need multiple deployment slots (e.g. app-a.azurewebsites.net and app-b.azurewebsites.net).
Maybe you can use virtual directory to upload multiple app projects in single webapp, this article explained it
Create projects
Assign virtual directory
Publish the root project
Set up virtual directory in azure portal
Publish the child projects

Recommended way to host a WebApi in Azure

I wanted to host my WebApi project on azure. But I am not getting sure which way should i use to run it on azure. Like there are Websites, Cloud Services that contain Web role and Worker role. Then which one should i choose. If cloud service is the option then which one out of Web role and worker role is good?
Any help is appreciated.
For hosting a simple web API (that you can scale according to usage, etc.) you'll want to use Websites. Assuming you're not looking for more complex / heavy-weight features (network configuration, more complex architectures e.g. offloading background processing different instances via queueing mechanisms, RDP into the host machine, etc.), then Websites are becoming the de-facto way to host websites on Azure.
The following page from the Azure documentation will give you a full feature comparison between the two:
http://azure.microsoft.com/en-us/documentation/articles/choose-web-site-cloud-service-vm/, but in short, if you simply have a web API project in VS that you want to host in Azure without worrying about the underlying infrastructure, then use Websites.
If you only want to host a Headless (No Web Interface) Web API, I recommend you using Azure Web Service - Web Role.
For Worker Role, it is like a console application that you want to use it to process background task. Normally, we use it to process from Message Queue (Azure Service Bus - Queue).
Azure create a Optimize VM to run those two type of Roles with no unnecessary junks. So you will get the most of it.
However, I still suggest you to read more detail document from azure website to see what environment which is best fit for your long term plan.
You need to login in Azure (https://manage.windowsazure.com) -> Web Sites -> Create New
After that you will find the Name of the Web Site Under the Web Sites.
Click Web Sites -> Select New Created Web Site -> Go TO -> Deployement
In Deployement -> Find -> Integrate source control
Select Appropriate Option i.e GitHub or Dropbox etc..
Using Dropbox => Now Publish your WebApi Project and Paste that Data into Dropbox Folder With the same name of your New Created Web Site in Azure
After Upload Go To -> Azure -> Select Web Site -> Deployement -> Sync.
It will take all the data from Dropbox and You can run your WebApi Project From Azure
More Details Link, Link2, Link3

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.

Categories