You’ve stumbled across the Microsoft Azure Web Sites Cheat Sheet – The quickest reference for getting to know Microsoft Azure Web Sites on the web. If you’re looking for some tutorials on how to develop solutions on Microsoft Azure Web Sites check out the Microsoft Azure product site.
Browse around this one page reference for information on command-line tools for managing your Microsoft Azure Web Sites. Take a quick look at the features that are offered on Microsoft Azure Web Sites then start exploring the wonderful world of Microsoft Azure!
Note: Features in gray are not available in Azure Websites. These features are available in Virtual Machines or Cloud Services as indicated by VM for Virtual Machines and CS for Cloud Services.
By default, Azure Websites comes preconfigured with Session affinity, which in many cases allows developers perform a very simple migration of their applications to cloud. This is because there is no need to worry about centralizing the session state of your application as a user will be redirected back to the same server on each subsequent request.
Some applications, however, may not require session affinity and it would be better to turn off the session affinity in Azure Websites. This can be achieved by adding the following to the web.config
file.
To ensure that the session affinity works during scaling activities, make sure to also add in an AppSetting with the following key value: clientAffinityEnabled = false
Based on your web application, you may want to restrict access to it. Access can be restricted by using the <ipSecurity>
element and providing a list of IP address to allow.
If you would like to whitelist azure resources, the Azure Datacenter IP Address Ranges are available online.
Dynamic IP Restrictions enable you to block access to your website when based on an interval of requests (i.e. Potential DDoS Attack). This can be achieved in a variety of ways as outlined in the example below.
You know those bugs where the only way to fix them is to restart the server every so often? There’s a web.config
setting for that! Microsoft Azure Websites have the ability to auto-heal based on a number of different triggers, i’ve outlined some of them in the example below. Note that this only works in Standard mode. It throws an error in Free or Basic mode.
Some big wins come in small packages, enabling HTTP Compression in your Website can help decrease your users mobile bill and wait time while loading your Web Application.
It’s possible that you may need to map mime types to IIS if you are going to serve static files.
Enable downstream caching of html for performance and cheaper delivery via Content Delivery Network (CDN). The snippet below enables 1 day, public caching of all HTML content.
When building out HTTP based APIs it is nearly impossible to enable functionality without being able to use certain HTTP Verbs such as PUT and DELETE.
Enable PUT requests using below web.config and make sure to change PHP Version number
For more information on HSTS, visit and read this blog post on How to Enable HTTP Strict Transport Security in IIS 7+ by Scott Hanselman.
The X-Powered-By header typically displays the Language and version information of a website which could be a potential security risk.
There are a number of ways to deploy your applications to Microsoft Azure Web Sites, there are also a number of ways to tie into the deployment process to aid you in Automation, Configuration, or Diagnosing issues with your deployment.
That's right, Kudu isn't exclusively for Microsoft Azure. Read the docs on How to Deploy Kudu on Windows Server 2012.
Have you forked kudu for your own purposes? Here's how you can deploy your custom fork of Kudu to Azure
Kudu is the central nervous system of a Microsoft Azure Web Site; it handles the Git integration to a Web Site as well as provides an API endpoint for programmatic access to app settings, deployment information, files, active processes, runtime versions, source control information, web hooks and web jobs. Kudu, itself, is a Site Extension which is provided with ever Web Site, you can access it by using the Source Control Management entry point https://<your-website-name>.scm.azurewebsites.net
The Kudu dashboard is the first page you will encounter on the SCM entry point, it displays information pertaining to your Web Site such as the build number of Kudu which is running, tge current uptime of your site (this could display a value as low as a couple of seconds as your site may have been deallocated due to inactivity, unless the site has Always-On enabled).
The Environment tab in Kudu Dash shows some very valuable information including System Information, App Settings, Connection Strings, Environment Variables, PATH, HTTP Headers and Server Variables.
The Debug Console gives file explorer and graphical KuduExec experience which enables you to run command line tools against the Web Site.
Diagnostic Dump provides a zip file of all of the Diagnostic Data which is enabled under the Application Diagnostics header in the CONFIGURE tab of the Web Site.
Log Stream long-polling process which provides logging data from your Web Site if Web Server Logging is enabled under the Site Diagnostics header in the CONFIGURE tab of the Web Site.
Allows URLs to be registered as Web Hooks. Information will be posted to the URL when events occur.
npm install kuduexec -g
KuduExec enables command-line access to a Microsoft Azure Web Site. Simply call KuduExec and pass in the Source Control Management (scm) endpoint of the website as the first parameter.
kuduexec https://[site-name].scm.azurewebsites.net Username: [deployment-user] Password: [deployment-pass]
npm install kudusync -g
KuduSync is a tool for syncing files for deployment, will only copy changed files and delete files that doesn’t exists in the destination but only if they were part of the previous deployment.
%DEPLOYMENT_SOURCE%
folder and the %DEPLOYMENT_TARGET%
.
command | options | description |
---|---|---|
|
So, you fancy programming PHP do ya? Well, here are some tips specifically for you.
Microsoft Azure Web Sites has a selection of default installed PHP Runtimes, however, the option is still available to bring your own runtime if a specific version of PHP is required.
PHP | WinCache |
---|---|
5.3.19 | 1.3.4.0 |
5.4.9 | |
5.5.3 | 1.3.5 |
fastcgi.impersonate = 1
and fastcgi.logging = 0
, too. Grrrreat.
In order to do this there are a few steps involved:
/site/wwwroot/bin/php
via FTP.Flll the boxes as follows:
Extension | Script Processor Path | Additional Arguments (Optional) |
---|---|---|
*.php | D:\home\site\wwwroot\bin\php\php-cgi.exe |
Configure a Handler Mapping via the command line:
Cross Platform Command Line Tools
**PowerShell Cmdlets**
Extensions can be enabled by adding App Settings to your Web Site with the following reserved app setting keys.
Key | Value | Description |
---|---|---|
PHP_EXTENSIONS |
|
used for loading PHP extensions with the built in versions of PHP |
PHP_ZENDEXTENSIONS |
|
used for loading zend extensions with the built in versions of PHP |
To enable the use of this ini
file, create an ini
folder within d:\home\site\
and drop the following xdebug.ini
file inside the folder. In the App Settings section of the portal, add a new App Setting PHP_INI_SCAN_DIR
with the value of d:\home\site\ini
. You must restart the App Service for these chances to take effect.
The Microsoft Azure cross platform command line tools enable the power of the Microsoft Azure Management Portal at the tip of your fingers on Linux, OSX or Windows. This guide details the command line options for creating, configuring and scaling Microsoft Azure Web Sites.
azure account download
to download a .publishsettings file which lists your subscriptionsazure account import <path-to-publishsettings-file>
to import your subscriptions to be available to the toolsazure account list
to identify which subscriptions were imported
azure account set <subscription-name>
to select the subscription to useazure account clear
General commands for Microsoft Azure Web Sites include the ability to create or delete a Web Site in Microsoft Azure. In addition, they allow you to control they underlying Web Server (IIS) with actions such as starting and stopping the site.
command | options | description |
---|---|---|
browse [options] [name] |
|
launch the website [name] in the default browser |
create [options] [name] |
|
create a new, or associate a local directory to an existing web site |
delete [options] [name] |
|
delete the web site [name] |
set [options] [name] |
|
Sets configuration options for your web site [name] |
show [options] [name] |
|
Show details for a web site |
start [options] [name] |
|
start the Internet Information Services (IIS) site |
stop [options] [name] |
|
stop the Internet Information Services (IIS) site |
swap [options]
[name]
new |
|
swaps the staging site into production |
restart [options] [name] |
|
stop, then start the Internet Information Services (IIS) site |
command | options | description |
---|---|---|
deploymentscript [options] |
|
Generate custom deployment script |
list [options] [name] |
|
lists deployed site |
show [options] <commitId> [name] |
|
shows details of the git deployment with the particular [commitid] |
redeploy [options] <commitId> [name] |
|
set specified [commitid] as the active deployment |
github [options] [name] |
|
setup a github service hook for specified web site |
user set [options] [username] [pass] |
|
Sets the deployment credentials |
command | options | description |
---|---|---|
branch <branch> [name] [options] |
|
set the branch in which to use for website deployment |
delete [name] [options] |
|
delete the remote git repository for the web site |
sync [name] [options] |
|
Sync your repository |
command | options | description |
---|---|---|
list [options] |
|
enumerate the data centers in which web sites can be created |
command | options | description |
---|---|---|
list [options] [name] |
|
Show your site application settings |
add [options] <keyvaluepair> [name] |
|
Adds an application setting for your site [semi-colon (;) delimitied] |
delete [options] <key> [name] |
|
Deletes an application setting for your site |
show [options] <key> [name] |
|
Shows an application setting for your site |
command | options | description |
---|---|---|
list [options] [name] |
|
Show your site certificates |
add [options] <certificate-path> [name] |
|
Adds a site certificate in pfx format |
delete [options] <thumbprint> [name] |
|
Deletes a site certificate |
show [options] <thumbprint> [name] |
|
Shows a site certificate |
Warning!
azure site config
has been deprecated and will be removed in a future release. Please use azure site appsetting
instead.
command | options | description |
---|---|---|
list [options] [name] |
|
list the app setting for the specified site |
add [options] <keyvaluepair> [name] |
|
add an app setting to the specified web site |
clear [options] <key> [name] |
|
removes an app setting from the specified web site |
get [options] <key> [name] |
|
gets the current value of web site app setting |
command | options | description |
---|---|---|
list [options] [name] |
|
Show your site connection strings |
add [options] <connectionname> <value> <type> [name] |
|
Adds a connection string to your site |
delete [options] <connectionname> [name] |
|
Deletes a connection string for your site |
show [options] <connectionname> [name] |
|
Shows a connection string for your site |
command | options | description |
---|---|---|
list [options] [name] |
|
Show your site default documents |
add [options] [name] |
|
Add a site default document (appended to list by default) |
delete [options] [name] |
|
Deletes a site default document |
command | options | description |
---|---|---|
list [options] [name] |
|
Show your site domains |
add [options] [name] |
|
Add a site domain |
delete [options] [name] |
|
Deletes a site domain |
command | options | description |
---|---|---|
list [options] [name] |
|
Show your site handler mappings |
add [options] [extension] [processor] [name] |
|
Add a handler mapping |
delete [options] [extension] [name] |
|
Deletes a site handler mapping |
command | options | description |
---|---|---|
delete [options]
<jobName> <jobType> [name]
new |
|
Delete a web job |
history list [options]
[jobName] [name]
new |
|
List all the triggered web jobs runs under a web site |
history show [options]
[jobName] [runId] [name]
new |
|
Get the details for a triggered web jobs run under a web site |
list [options]
[name]
new |
|
List all the web jobs under a web site |
show [options]
<jobName> <jobType> [name]
new |
|
Show details of a specific web job |
start [options]
<jobName> <jobType> [name]
new |
|
Start a web job |
stop [options]
<jobName> <jobType> [name]
new |
|
Stop a web job. Only continuous jobs can be stopped |
upload [options]
<jobName> <jobType> <jobFile> [name]
new |
|
Upload a web job |
command | options | description |
---|---|---|
download [options] [name] |
|
Download diagnostic log |
tail [options] [name] |
|
live diagnostic log |
set [options] [name] |
|
Configure diagnostics |
command | options | description |
---|---|---|
mode [name] <mode> |
|
Sets the web site mode |
instances [name] <instances> [size] |
|
Sets the web site number of instances |
The Microsoft Azure PowerShell Cmdlets enable the power of the Microsoft Azure Management Portal straight from the PowerShell command window. This guide details the command line operations for interacting with Microsoft Azure Web Sites.
Get-AzurePublishSettingsFile
to download a .publishsettings file which lists your subscriptionsImport-AzurePublishSettingsFile <path-to-publishsettings-file>
to make your subscriptions available to the PowerShell command-line.Get-AzureSubscription
to identify which subscriptions were imported.Select-AzureSubscription <Name>
to select the subscription to useGet-AzureSubscription | Remove-AzureSubscription
These Cmdlets enable the ability to create new Microsoft Azure Web Sites with options to associate a local Git or GitHub repository to your site. The Cmdlets also allow the deletion of Web Sites from your subscription.
parameter | description | parameter help |
---|---|---|
|
The name of the Web Site |
|
|
The data center where the website should be deployed |
|
|
An alternative hostname for the new azure website. |
|
|
The username you have specified in the Microsoft Azure Portal for Git deployment |
|
|
Set up a local git repository and link it to the website. If specified, this will set up a git repository in the local directory and add a remote named 'azure' that links to the website in Microsoft Azure. |
|
|
If enabled, link this website with an existing Github repository. Commits to the Giuthub repository will be pushed to the website in Microsoft Azure. |
|
|
The username and password credentials used to connect to Github |
|
|
The full name of the Github repository to link to this website. For example, myaccount/myrepo |
|
parameter | description | parameter help |
---|---|---|
-Name <string> | The name of the Web Site |
|
-Force | If specified, bypass confirmation prompts and delete the specified website |
|
These Cmdlets enable the ability to list or set configuration settings in Microsoft Azure Web Sites.
parameter | description | parameter help |
---|---|---|
-Name <string> | The name of the Web Site |
|
parameter | description | parameter help |
---|---|---|
-Name <string> | The name of the Web Site |
|
-SiteWithConfig <SiteWithConfig> | The configuration used by the website |
|
-NumberOfWorkers <Int32> | The number of worker processes executing the website |
|
-DefaultDocuments <String[]> | The documents that are automatically displayed when browsing the website |
|
-NetFrameworkVersion <string> | The version of the .Net Framework required by the website |
|
-PhpVersion <string> | The PHP version required by the website |
|
-RequestTracingEnabled [<Boolean>] | Determines whether request tracing is enabled for the website |
|
-HttpLoggingEnabled [<Boolean>] | Determines whether http logging is enabled for the website |
|
-DetailedErrorLoggingEnabled [<Boolean>] | Determines whether detailed iis errors are logged for the website |
|
-HostNames <string[]> | The fully qualified hostnames that can be used to access the website |
|
-AppSettings <Hashtable> | The environment variables that will be used by the website |
|
-Metadata <NameValuePair> | The Metadata for the website |
|
-ConnectionStrings <ConnStringPropertyBag> | The connection strings used by the website |
|
-HandlerMappings <HandlerMapping[]> | The Handler Mappings used by the website |
|
-PassThru <Switch> | When specified, a boolean value is returned |
|
These Cmdlets enable the ability to start, stop or restart a Web Site. The Cmdlets also launch the Web Site in the default web browser.
parameter | description | parameter help |
---|---|---|
-Name <string> | The name of the Web Site |
|
parameter | description | parameter help |
---|---|---|
-Name <string> | The name of the Web Site |
|
parameter | description | parameter help |
---|---|---|
-Name <string> | The name of the Web Site |
|
parameter | description | parameter help |
---|---|---|
-Name <string> | The name of the Web Site |
|