Create a Simple Azure Web App with PowerShell

Hello, this post will show you the steps to create a free, very simple web app in the Microsoft Azure platform using PowerShell.

You will need an existing subscription or sign up for a new one to follow this post. The app service plan selected is the free tier so you will not be charged / count against your Azure credits.

Visio diagram of azure resource group, app service plan and web app

Use must have Azure PowerShell installed. You can get it from the Azure Microsoft site.

azure-powershell

Authenticate to Azure using Azure Resource Manager:

You can list your subscriptions with the following command (the command on the second line will output just the subscription names):

Select the subscription you want to use:

Create a Resource Group:

Tags are a great way to manage resources and are created in PowerShell using a hashtable.

Create an App Service Plan:

Create a Web App:

Note: The web app name must be globally unique. Creating the web app will create the URL: http://webappname.azurewebsites.net.

If your deployment fails, check for the error message: New-AzureRmWebApp : Website with given name simple-web-app134 already exists.

Change the name of the web app or add a random number onto the end.

That’s it. You should now be able to browse to the default template by entering the URL: yoursitename.azurewebsites.net.

Browsing to the newly created site in google chrome http://simple-web-app134.azurewebsites.net/

To delete all of the resources (warning, this will delete everything in the resource group, make sure you are targeting the correct resource group). Add the -Force switch parameter if you don’t want the confirmation prompts:

This is handy when using the app service plans that cost money. I sometimes create a standard plan for trying out deployment slots, so I will use it while testing, then delete it afterwards. If I need it again, I’ll simply run the PowerShell commands again.

I’ve scripted this out and put it on github with variables if you’re interested in taking a look.

That’s it for now, cheers.

Azure Active Directory Connect Unable to connect to the Synchronization Service

Error message when trying to run Azure Active Directory Connect = Unable to connect to the Synchronization Service. Some possible reasons are: 1) The service is not started. 2) Your account is not a member of a required security group. See the Synchronization documentation for details.

Unable to connect to the synchronization service

Check Service

First check the service is running. Use services.msc or PowerShell.

If it’s stopped, start it.

Run the Synchronization Service as administrator

From Taskbar

Right click Synchronization Service icon

Right click Synchronization Service

Select Run as administrator

run as administrator from taskbar

From Apps menu

Right Click on Synchronization Service

Select Run as administrator

runas administrator from apps menu

 

 

Azure backup server, SMTP with anonymous authentication

While configuring an Azure backup server, I was trying to set the SMTP settings with anonymous authentication to email notifications, but kept getting the following error:

ID: 2013
Details: The user name or password is incorrect

ID: 2013 Details: The user name or password is incorrect

Quick Fix

Create a local user (with stupidly long and complex password). Add the user to the Adminstrators group. Use these details for the Username (servername\username) and Password.

Overview

To configure the SMTP server settings go to Management on the left hand side

Azure backup management menu

The click Options in the tool bar across the top.

Azure backup options button

Ideally, I did not want to enter any details here because there because it technically there aren’t any (our SMTP server is provided by our ISP and is authenticated by our IP address). I kept getting the ID 2013 error. When I used a domain user, I still got the error. Creating a local user and using those details, the same error. It was only when I made the user a member of the local Administrators group was I able to send a test email successfully.

Azure backup SMTP server settings

Despite it saying “The username entered should domain account name of person whose “From” address is mentioned above, otherwise notification delivery will fail” it didn’t matter. A local server account was fine as long as it was in the Administrators group… not ideal but at least notifications will work.

This issue is in Data Protection Manager (DPM) and thanks to this post, Anonymous SMTP for DPM  which gave me the solution of adding the local user to the Administrators group (number 2 on the page, deleting the registry keys as described in solution 1 did not work for me).

 

Cheers.

Azure PowerShell login and create resource group

I’ve been doing lots of work with Azure recently (especially using PowerShell) so thought I’d dump some of the stuff I’ve learnt along the way here… it’s been a while.

This small guide will show you how to login to Azure using PowerShell, view and select your subscriptions and then create a Resource Group that will be provisioned in the Azure Portal.

I’ve messed about with the classic portal a bit, but Resource Manager (RM) is the way to go… you’ll see Rm in the PowerShell nouns to signify that it is a Resource Manager cmdlet.

First you need to install Azure PowerShell to get all that Azure PowerShell goodness… once you’re done (the instructions are clear and easy to follow) come back here and continue below.

Login to your Azure RM account

Get Azure RM subscriptions

Set your Azure RM subscription to work in (one of mine is called Pay-As-You-Go)

Create an Azure RM resource group

This creates a Resource Group called ps-test in the North Europe region with the tag “Created By Matt”

Go to the portal and you should see the newly created resource group (make sure you have selected the correct subscription if you have more than one).

Azure Resource Group deployed by PowerShell
Azure Portal

 

Tags are great and an excellent way to organise your resources, you can also use them to report on costs and usage.

That’s a simple demo of login into Azure with PowerShell, selecting a subscription and then deploying a resource group which is used as a container to help keep track of resources for VMs, Apps, Databases etc.