Make the Web App on Azure portal only Available few hours in a Week - asp.net-mvc

I am building a ASP.Net Core Web App which I am trying to host in the Azure portal. We have requirement that these Applications can be accessed only certain times in a week, those times are stored in the Azure Database. Is it possible to make the App Available/Accessible to the users upon looking at database
Here the Setting is that the application should be available only between 14:00 - 16:30 on TUESDAY. When I tried to research we can schedule tasks/workflows in the portal but couldnt find what I am looking for. All I wanted to know is this requirement possible, if so please share the idea.. I am new Web App development and Azure deployment, any help is greatly appreciated

This feature is not available in Azure out of the box. This is something you will have to handle yourself.
One obvious way to implement this would be to check if the application should be available on every request. If the request day and time falls between the available times set in the database, you show your users the website content otherwise show them some kind of not available message.
A more complicated way would be to make use of App_offline.htm file to make your site unavailable. You can dynamically add/delete App_offline.htm file to your WebApp based on the day/time when you want your site to be offline/online.
However please note that while your site is offline, you will still be charged for the WebApp as the resources keep remain provisioned.

You can use Azure Automation Service to orchestrate processes like this. You will have to create a runbook (script in python or powershell) that will query the DB and figure out the times when the Azure Website hosting your webapplication should be started or stopped.

Related

Create one or multiple credentials for different projects using OAuth 2.0 client IDs?

I first created a Google API project on Google developer console and configured a OAuth 2.0 client IDs as credentials in order to let my C# projects to access the Google Drive.
However, I'm new to developing with Google APIs I am not able to understand when i should create new credentials or projects.
Should I create multiple credentials (maybe one credentials for one project?) or actually it's fine to use the same credential for multiple projects? What's the purpose to create more than one credential?
If you are creating different applications then you should create different projects on google developer console each with their own set of credentials.
The reason for this is to ensure that you dont run into any issues with quota. It also allows Google to track who is using their data and how much.
You should also consider when you define your project and create credentials you are giving it an name. When a user authenticates your application they are granting access to Super app one to use their data if you use this client with Super app two then they wont know who has access to their data.
My personal rules
Each application is a project on Google developer console.
in that project i create a client id for local, test, and production environments.
Update from comment about project creation quota
My current project quota
You have 37 projects remaining in your quota. Learn more.
You can always request additional projects do it early from what i remember it took a week or so to get them. Project quota requests
Update usage to create multiple credentials for same project then
Like i mentioned before if you use the same project for credentials on different projects you are miss leading your users. The fields i have marked with arrows denote an APPLICATION they are specific to the application requesting access. They are part of the project itself. All of the clients created under that project are going to use the same consent screen. If you use it for two different applications you are IMO miss leading the users in what application they are granting access to their data.
You may also be miss leading Google as i believe the TOS requires one project per application making a request hence the consent screen having application name and link to the application contacts. However i think i need to read though the TOS doc again to make sure this is a requirement.
You are also more likely to hit quota limits. A lot of the limits are project based not credential based so if you have two applications reading from the same api with two different credentials created under the same project. You are going to hit the quota a lot faster than if you had created each application its own project.
Example: Google Analytics example max project request 50000 per day.
Same project
Application one requests 20000
Application two requests 30000
both application one and application two are now blocked from making requests for the rest of the day as they have in totally hit 50000 requests.
Two separate projects
Application one makes 30000 requests
Application two makes 50000 requests.
Application two is now blocked for the rest of the day as it made 50000 requests. Application one continues to work until it has also hit 50000 requests.

How to shutdown one instance of an app service in azure

I have deployd an Asp.Net MVC application to an app service in azure and scaled it out to 2 instances.
Sometimes I need to restart an instance, but I only find a way to restart the whole web app. Is there a way to restart one instance only? Even removing the instance and then creating a new one would work for me.
There is no super clean way to do this, but it is still possible to achieve with the following steps:
Go to the Web App in the portal
Choose Process Explorer from Tools menu
You'll see processes for all instances. You can right click on specific w3wp's and kill them, which effectively restarts the site. You don't have to kill the Kudu process (the one with the K icon) if you only want to restart the site. For WebJobs, kill Kudu as well.
You can now restart an instance of an App Service Plan from the App Service Plans - Reboot Worker page in the Azure docs. You can restart the instance directly from that page using the 'Try it' feature.
Visit the Reboot Worker page
Login using an account from the Azure tenant containing the App Service Plan
Click 'Try it'
In the right hand pane enter the Name of the App Service plan and the resource group which contains the plan
Select the Azure subscription which contains the App Service plan
Enter the name of the work machine (instance) you wish to restart. This value typically starts with RD and may be found using the metric and diagnostic tools for the Web App in the Azure Portal.
Click the green Run button at the below the request preview.
If you are using App Services then, unfortunately, this is not possible. You can only update the no. of instances.
But as an alternative, you can decrease the number of instances and then increase back again. Or if you want more granular control, for any reason, then you can deploy the web app in IaaS Virtual Machine workloads and setup instances manually.
At the time of this posting, there is a Health Check (Preview) feature mentioned in the Azure Portal under the "Diagnose and solve problems -> Best Practices" blade for an App Service.
Health Check feature automatically removes a faulty instance from rotation, thus improving availability.
This feature will ping the specified health check path on all instances of your webapp every 2 minutes. If an instance does not respond within 10 minutes (5 pings), the instance is determined to be unhealthy and our service will stop routing requests to it.
It is highly recommended for production apps to utilize this feature and minimize any potential downtime caused due to a faulty instance.
Note : Health Check feature only works for applications that are hosted on more than one instance. For more information check the documentation below.
You can restart individual instances using "Advanced Application Restart", which you can find under diagnostic tools for your App Service in the Azure Portal.

Publishing MVC app on web

I am trying to publish my app on the web. It is very simple app, I have just start to learn MVC. To publish my app I have followed the instructions given at http://www.asp.net/web-forms/overview/deployment/visual-studio-web-deployment/deploying-to-iis. However I cannot see app from other PCs. I see it in browser from the PC where I have created it, but when I try to open it from another PC it is not visible, the link I am trying to access is the one I created during publishing - http:/localhost/WebApplication1. I am not sure what I am doing wrong. Or maybe the example I followed is not correct for the thing I want to do. Could,please someone tell me what I am doing wrong? Thank you in advance.
If you publish your site on localhost, you'll see it only in your local network. To publish it on the web, you'll need some web hosting service. You can try, for example, Microsoft Azure, it works perfectly with ASP.NET (not too surprisingly, as it comes from Microsoft), has a 30 day free trial period and otherwise is relatively cheap for low usage.

Launching site in beta, how to proceed

I have a site which has login functionality where a user can register an account. I want a certain number of people to test it before launch.
My plan was to create a bunch of random keys in my database that can only be registered once then have them proceed.
On the flip side I vaguely remember some web services to properly manage beta launches to facilitate all these tasks and receiving feedback etc.etc.
Any suggestions, is my plan common practice, am I reinventing the wheel?
Prefinery is a web service that manages this process.
Best of luck with your launch!
Just make a few test accounts for the users you want to test your site. You could run the site on a subdomain until you feel that the site is ready to go "live". If you want them to test the registration process as well, limit the amount of users that can register using a DB count query.
I'm not aware of any beta testing software.
Good luck.

Asp.net mvc app on a shared host move to Windows Azure during peak load possible?

I have an ASP.NET MVC web application that is hosted on a shared hosting account. The site has no issues during regular usage. However the nature of the business is such that for one week out of the month we have very very high traffic. During these high traffic peak load times, my application has several "Service Unavailable".
One of the possible solutions I am looking at is to spin up a Windows Azure web role during peak traffic week and spin it down again after the week is up. (I know exactly when the load is going to be high) Right now, we don't have enough revenue to justify moving the site permanently to the cloud.
My questions is how to I handle DNS. I would like the move to Azure and back to hosted service to be seamless to the user. The user should be able to type my normal URL and go to my hosted site during off peak weeks and to the cloud app during peak week. My guess is to add some kind of CNAME record to the DNS server but I have no idea how to go about doing this. Anybody know of any resources on how to update the DNS so this scenario would work?
Yup, a CNAME record sounds to me like the way to go. See http://blog.smarx.com/posts/custom-domain-names-in-windows-azure. (Sorry, one of the images looks broken... I'll try to patch that up.)
The scheme would be: have www.foo.com point to your current app instance, and then change it to point to something.cloudapp.net when that week comes up... then switch it back after the rush is over.
Is it possible to just have the MVC site hosted on another web hosting account permanently? It doesn't necessarily have to be an Azure account, does it? Is the site written in MVC1 or MVC2?
If your shared hosting server cannot handle the peak then 1 instance of the web worker role in Azure probably won't work either.
I would try something else: keep your asp.net code on that server but move all the static content somewhere else (for example the Azure CDN) using a subdomain. If you use Jquery and serve the file from your website then you can change the link to either Google's CDN or Microsoft's CDN already for free.

Resources