How do you execute elevated cmd on Azure website? - azure

I have a Classic ASP website hosted on Azure (migrated now, rewrite later) and found there is a dependency on AspEmail.
To register on a normal IIS box the command is:
regsvr32 c:\AspEmailDir\AspEmail.dll
The SO answer here shows how to do this with a webrole but I have a website.
I was thinking a WebJob might work, or is there some other way?

I don't think you will be able to do this on Azure website. I see two solutions here:
Move to web role. Then you can execute this via startup task.
Get rid of AspEmail or move it to a separate worker role.

Related

Node js web app restart issue

js site which i deployed on Azure.
Site was working fine but i made some changes but changes not appearing on the site. How to restart or clear site cache on Azure portal.
One more thing that post methods are not working in this site as well how to enable post method in Azure ?
I already tried to restart my web app from Azure portal but not success.
Posted my issue https://social.msdn.microsoft.com/Forums/en-US/090831ae-41ff-4091-a7ec-466041904c10/nodejs-app-restart-cache-issue?forum=windowsazurewebsitespreview here as well
First of all, you could restart your app by following steps below on Azure portal.
In the Azure Portal, open the blade for the web app.
Click Overview.
Click Restart button to restart your app.
Secondly, you could check the code whether it has been changed on Azure with Kudu which could be accessed via https://<yourwebsitename>.scm.azurewebsites.net/DebugConsole.
Then cd to site/wwwroot folder, you will now be able to see your application files.
By default, Azure doesn't restrict any HTTP request method. Maybe you have made a mistake in configuring web.config file, which can be found on this article. You can check this official guide if needed.

What is a web job on azure, is it part of a web application or standalone

Is it a job attached to a web app, or is it a type of web app itself? I tried following this example but couldn't find the add webjobs link it mentioned, just links to create a web app.
https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/
Yes, a job is "attached" to a Web App. A Web App is the execution container for WebJobs. In some cases you might also have a companion website also running in the WebApp, but often, the Web App only contains WebJobs.
Once you have a Web App, you can create/manage WebJobs via the portal "WebJobs" blade in the new portal. You'll find it in the Settings blade under "Features".
Another way to think of a Web Job is as an extra .exe/process that runs on the same VM as your web app, with the only special thing being that it is launched with the same set of environment variables as the web app and has access to the same set of directories.
There's a great post here explaining WebJobs and how to create/operate one. Everything you need to know to get going.

How to get .publishsettings for Web Deployable Web Role?

I enabled the Web Deploy feature for my Web Role and deployed it.
But how can I get hold of the .publishsettings file so I can create a Publishing Profile for it?
This 2 year old article states that it should have been created automatically, but I haven't got that in my profile manager.
Any ideas?
If you are using Visual Studio 2012 or greater, the server explorer to the left will have several Azure items.
Specifically the Windows Azure Compute is what we are looking for, right click on that and say 'add deployment environment'. You will then be prompted with a dialog that allows you to sign in and download publish settings file:
You can get publishsettings file from the following link: https://windows.azure.com/download/publishprofile.aspx
Well, the problem was really behind the keyboard.
So the publishing profile is actually provisioned correctly and automatically to the Web project as the documentation states.
The problem and confusion was that I have a secondary web application in my Solution that I also publish to the same Web Role (referenced as an additional Site in the ServiceDefinition.csdef file).
That Web Project does not get the Publishing Profile, and when I try to create a profile manually, it doesn't work since that (secondary) IIs instance is not configured for Web Deployment.
Oh well, back to the tedious Cloud Service deployment it is...

create site in IIS with powershell

Working with an mvc4 application that runs in IIS 7.5, the site though exist once on disk, has over a 100 url's pointing to it. This is because the site displays content based on the country that needs to access it.
Due to this, the site can have over a 100 bindings, which is very hard to manage.
I am looking to automate the creating of the site in IIS using powershell. I would run this during each deployment to ensure each of my environments are identical (dev, qa, production).
The powershell script would delete the site and recreate it, applying bindings, configuring it etc. I am a newbie to powershell so I would appreciate any help with this.
You should be able to use the PowerShell IIS Administrative Cmdlets. I show how to automate creating and deleting web applications using them on my blog that should get you started.
I have a script I use when creating a website and AppPool in IIS 7+ (under .net4, Integrated pipeline, etc) and thought you might find it useful as its a bit simpler than some of the other answers. It will delete the site and replace it if it already exists making it good in continuous integration scenarios.
Use it as so:
CreateSite.ps1 [WebsiteName] [AppPoolName] [Port] [Path]
If you are reinstalling the site, you will need to stop it first. That is done as so:
StopSite.ps1 [WebsiteName] [AppPoolName]
you gan grab the scripts from my gist
There is an IIS provider for PowerShell which you can use to manage IIS from PowerShell.
Take a look at the available cmdlets.

How to give Website permission to create further Websites in IIS 7.5?

I'm creating a website in IIS 7.5 (with Windows 7) that needs to be able to create further websites. I've written code that uses Microsoft.Web.Administration to create the website programmatically, and this works fine when I run it as administrator.
Now I'm trying to use the same code in the context of my web application. It fails with the error
Error: Cannot read configuration file due to insufficient permissions
for the file redirection.config (which I understand is located in %WinDir%/System32/inetsrv/config).
I've tried creating a new apppool for this specific website, running under the IIS AppPool[AppPoolName] identity. I've then tried to grant that identity permission to edit the IIS config using
ManagementAuthorization.Grant(#"IIS AppPool\MyAppPool", "Default Web Site", false);
but I still get the same error.
What else should I try?
This probably isn't the wisest approach from a security viewpoint. If this site is hijacked then your attackers will be able to interfere with those files (to no good purpose) or even just delete them.
The way we approached this was to separate website creation tasks into a windows service running with the correct rights to perform these activities. In this service is a remoting end point (although these days you'd probably want to use WCF).
We then created a proxy assembly that is signed and registered in the GAC (it would also need to be marked with the APTCA attribute if you're running at less than Full Trust). This assembly passes on the relevant calls to the remoting endpoint in the windows service from the admin web app/service.
This allows us to run the admin site at least privilege and in partial trust mode. The scope of what can be done by way of site admin tasks is narrowed somewhat by whatever functionality is exposed in the windows service application.
This is a technique known as sandboxing.
I've found a way to do it, but I would very much like to hear expert opinion on whether this is a wise thing to do.
I granted Modify and Write permissions for the IIS AppPool\MyAppPool account to %WinDir%/System32/inetsrv/config and the three .config files inside it.

Resources