Microsoft Azure Web Role - c#

I have hosted my website in microsoft azure web role. My website works like application and service. Each time user approaches the site, request goes to the service, finishes its database related queries and return backs to application part. Since it has two ways, i have used web roles for both application and service.
If the number of users reaches maximum, an instance is created in web role, what would happen to my service side since it involves database related things.
Everytime when the instance is created, would database be created along with that?
In my case, i would like to see everytime instance is created, no duplicate database should be created. Is it possible? If its possible, do deadlock occurs in that case?
Is it possible to host a application and service both in same web role. If so, i would like to see only database should be created each instance is created.
Please provide a clear solution on this.

Assuming that the application and service are running under two separate cloud services:
Your Application and Service roles are configured to scale independently.
Assuming your are using an Azure SQL Database, it would also be scaled independently of the cloud service.
No duplicate database would be created - Azure SQL databases would again be scaled independently of the cloud services.
If your Application is, say, an ASP.NET MVC application, and your service is a WebAPI, they could both be hosted under the same cloud service (they'd be in the same web application)
How your Service application would behave in a scaled scenario will really depend on how it's been implemented.
I think you have a misunderstanding about how scaling works with Azure.
Check here for some additional detail: How to Scale a Cloud Service
As an aside, you may want to consider Azure Web App instead of a Cloud Service. Whilst they offer less control that a cloud service, unless you are doing something specific that an Azure Web App can't offer, they are easier to deal with.

Related

Publishing a C# console application as an Azure web job

I've got a console application, with logging, scheduling, etc., running on a VM. It works with Entity Framework, Azure SQL Server, Azure blob storage and a bunch of external APIs.
I'd like to turn it into a service.
I understand that this can be done with worker roles, but looking at various tutorials for worker roles, it seems like it would be a ton of work to rewrite the whole thing.
If I just publish it as a web job, will this be secure, assuming I don't have any exposed endpoints? I need to make sure that nobody outside our active directory can access it.
Is there a way that I can create a dummy app service which will have no endpoints and publish it there?
If I just publish it as a web job, will this be secure, assuming I don't have any exposed endpoints? I need to make sure that nobody outside our active directory can access it.
As Peter Bons said, if it does not expose an API or endpoint, nobody can access it.
Is there a way that I can create a dummy app service which will have no endpoints and publish it there?
Normally we run WebJobs in a Azure App Service web app, and that Azure App Service web app can be accessed/browsed via URL. If you want to prevent users from browsing to that Azure App Service web app, you can add a rewrite rule to site’s web.config to block web access.
<rule name="Block unauthorized traffic to staging sites" stopProcessing="true">  
<match url=".*" />  
<conditions>  
<!-- Enter your site host name here as the pattern-->  
<add input="{HTTP_HOST}" pattern="^sitehostname\." />  
<!-- Enter your white listed IP addresses -->  
<add input="{REMOTE_ADDR}" pattern="123\.123\.123\.1" negate="true"/>  
<!-- Add the white listed IP addresses with a new condition as seen below -->  
<!-- <add input="{REMOTE_ADDR}" pattern="123\.123\.123\.2" negate="true"/> -->  
</conditions>  
<action type="CustomResponse" statusCode="403" statusReason="Forbidden"  
statusDescription="Site is not accessible" />  
</rule> 
what exactly your exe is? will someone invoke it and scheduled to run on a regular intervals?
we have couple of options here, if the processing logic is not a complex one you can go for Azure functions which uses WebJobs SDK itself but doesn't require an App Service to be configured for it.
or you can go for Azure Scheduler which can take your executable and run at a scheduled intervals.

Handle external WCF Service calling internal WCF Service (auth - session)

i need to build this architecture and i need some orientation on "how should i build". I've read many docs and examples but i can't find and figure how to do trying to be efficient and secure:
External app (android app, ios app) where users, after a login, can access to their personal info and manage the account (updating personal data, showing personal documents related to their account and much more). The username / pwd input must be done only 1 time.
A public wcf service will receive their actions and will call to a another internal wcf service. It will work like a 'bridge'.
The internal wcf service will get the request and do the operations needed (logical and db operations). This will return data to the external wcf service and this one to the client (obvious).
UserName/PWD are stored in a database.
WCF services can only be accessed with the correct credentials and are IIS hosted.
So i find many problems/questions:
I don't know HOW and WHERE should I build the AUTH (internal, external, both?). How can i manage a session between wcf services and app clients to avoid sending credentials every time?
The client app needs to send credentials every time? This means every service requires to SELECT the database for checking the username?
SOAP? Rest Services? It doesn't care? (on internal wcf, external wcf, both?).
I need work with asp.NET sessions or i really don't need? I don't see how services that needs username/pwd that are called frequently and repeatedly are efficient without old asp.net sessions.
Thanks for your help and orientation.
Regards!
If someone interested... seems Routing Service seems to fit for my design and can solve my problem after some tests i have done.

Azure Configuration for API + SQL Storage

I'm working on a project that includes an ASP.NET Web API site to be consumed by an Android and iOS app. The API is connected to a SQL Server database. I'm at a point where I want to publish my project to the Azure Cloud, but am trying to figure out what would be the best configuration.
The configuration needs to be scalable and reliable as the plans for this product will be accessed by many at the consumer level.
API Hosting
What do I use within Azure to host the API? Do I go with the Azure Web Site service? Or the Cloud service? or something else? I know I don't want to go Virtual Machine as I don't want to have a lot of maintenance.
One thing I should add here, I plan on having a Test/Qual environment as well as a Production environment in Azure.
SQL Database
This one seems easy for me, I will need to utilize the SQL Database service through Azure.
Scheduler
I have one final need of various jobs that need to run at night on some form of schedule. Would you agree that utilizing the Azure Scheduler service would be much cheaper than having either a Cloud service or Virtual Machine running scheduled tasks? Instead I could use Scheduler to utilize various web services at set times?
While Azure Web sites and Azure Web roles (cloud services) are very similar, the below are the most notable differences in my opinion:
Web Roles are cheaper than Web sites. There is a free offering for websites, but it has significant drawbacks.
Web sites are easier to manage and operate
You can deploy web sites from git.
You can use remote desktop to connect to Web roles.
You can use Worker Roles for background tasks from Web roles. Recently Websites introduced web roles which lessens the need for worker roles, note that this is as of today still in beta.

IIS7.5 - Configure impersonation whilst using an app pool configured with a named domain account

I am deploying a .NET web service that connects to a database.
When a user within the domain connects to the webservice, I want their identity to be known by the webservice (since a subsequent call to the DB from the webservice uses a USER_ID() function to know which user is making the request).
The app pool that is running the web service is configured to run under a domain account that allows access to the database. When I query the web service, it is connecting as that account of the app pool, and not the user that is calling the web service.
I have tried various different impersonation configurations but I can't get the web service to interpret the caller's identity. Can anyone advise what I am doing wrong? Is the fact that my app pool that is running under a named account causing the problem? Should it be configured to something else?
No, it's not the app pool's problem. Impersonation has to be also set from configuration files which in fact, it's probably already been specified.
Now, you didn't mention what of service you are using. For the service to be aware of who is making the request through impersonation the service must be running in asp.net compatibility mode so it can participate in the asp.net pipeline. It's a pretty basic topic, but if you need more info, then refer to the MSDN article below
http://msdn.microsoft.com/en-us/library/system.servicemodel.activation.aspnetcompatibilityrequirementsattribute(v=vs.110).aspx
Leo

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