Wednesday 17 February 2016

Get started Office 365/SharePoint Online dev with an Azure VM – part 1: Create trial environments and a VM

I’m always surprised by the number of roadblocks which developers in large organisations have to face. Whether it’s locked-down desktops, lack of virtual machines (or very low spec virtual machines), inadequate licensing for developer tools, or any of the other myriad of issues, it can be frustrating trying to get started with new technologies. I often talk to developers in such companies, and often see some reluctance to do things which I find myself doing fairly frequently to test things out – creating a trial Office 365 environment, spinning up a virtual machine in Azure, downloading/testing an Office 365 or SharePoint app and so on. Recently I put together a guide to steps like these (for attendees of a Microsoft dev event here in the UK), and I thought it might be nice to repurpose the guide for other newbie developers in case it’s useful. This is split into two articles:

  1. Get started – part 1: Create trial environments and a VM (this post)
  2. Get started – part 2: Get started with developing SharePoint Add-ins (apps)

I guess the type of SharePoint developer this is aimed at is:

  • Doesn’t have access to an Office 365 environment to play in – may not even have touched SharePoint Online before
  • Isn’t able to quickly obtain a new virtual machine
  • Doesn’t have an MSDN license
  • May not have touched Azure before
  • Needs a developer environment with the latest version of Visual Studio to look at/run code locally (i.e. hosting apps on https://localhost). Perhaps their existing desktop or virtual machines aren’t appropriate for this

If one or more apply to you, you might find this useful. We’ll go from creating the Office 365 and Azure dev environments, to downloading and running a sample app (a provider-hosted SharePoint Add-in) from Microsoft’s OfficeDev Patterns and Practices samples. This can help someone experience add/add-in development for the first time, but it can be just a generally useful set of steps that can be handy in several scenarios.

Disclaimer!

Although I've taken care with these steps, I make no guarantee they're 100% accurate/will work in all regions/at all times, and can't really dedicate much time to support around this topic I'm afraid! Hopefully they're enough to get you up and running though.

Here’s what is covered:

This post:
  • Create trial Office 365 E3 tenant
  • Create a trial Azure subscription
    • NOTE – you WILL need a credit card for this step unfortunately. BUT, it’s possible to avoid spending money, since you receive credit to the value of £125 and by default, the Azure subscription is “locked” to prevent further charges. This will enable you to get started at least
  • Prepare the SharePoint Online tenancy for apps – create an App Catalog etc.
  • Create a development VM in Azure with Visual Studio 2015
  • Prepare Azure VM for development (e.g. enable IIS and ASP.NET, install the OfficeDev tools for Visual Studio etc.)
Next post:
  • Walkthrough of deploying a provider-hosted SharePoint add-in in your VM (next post)
  • Create a self-signed SSL certificate
  • Create a local website in IIS to run apps
  • Download the SharePoint Add-in from Github and run locally
Create a trial Office 365 environment (E3)

In this step, we’ll create a trial Office 365 environment to enable us to do some development. Note that another option here is to sign-up to the Office 365 Developer program – this will provide you with a tenant which will last 365 days, but only contains one user. If I’m just spinning up something which I don’t care about being durable, I often prefer to create an E3 trial – this only lasts for 30 days, but comes with 25 users. Both options are useful (depending on what you’re doing), but in this case we’ll go through the process for creating an E3 trial.

To do this, navigate to the Office 365 Enterprise E3 product page (the UK version of this page is at the following link, but simply change the market using the selector at the bottom of the page if you are in another country - https://products.office.com/en-GB/business/office-365-enterprise-e3-business-software?omkt=en-GB). Click the “Free trial” link on this page:

clip_image002_thumb2[10]

Enter some details into the form and click “Next”:

clip_image004_thumb2[4]

On the next screen, provide a username and also select a prefix for the “.onmicrosoft.com” domain – NOTE, this must be unique in Office 365, so you may need to try a few names until you find one which is unique:

clip_image006_thumb2[4]

Click “Next” when done. On the next screen, provide your mobile phone number to receive the text message verification. Once entered, click “Text me”:

clip_image008_thumb2[4]

Enter the code in the box provided, then click “Create my account”:

clip_image010_thumb2[4]

On the next screen, make a note of the user ID you provided and then click the “You’re ready to go…” link:

clip_image012_thumb2[4]

Your Office 365 environment is now creating – this will take around 20 minutes:

clip_image014_thumb2[4]

Prepare Office 365 tenant for development

Once your tenant has finished provisioning, go to the Admin Center and navigate to the SharePoint area. If your tenant is using the current Admin Center experience (rather than the new preview experience), the link is here:

clip_image016_thumb2[4]

Once in the SharePoint area, navigate to the “settings” page:

clip_image017_thumb2[4]

On this page, scroll to the “Custom Script” section. Change both radio buttons to the “allow” option to enable custom scripts to execute. The radio buttons should look like this:

clip_image019_thumb2[4]

Click “OK” to save the settings.

Now go into the “apps” area, and select “App Catalog”:

clip_image020_thumb2[4]

Ensure the option to create a new App Catalog site is selected, then click “OK”:

clip_image022_thumb2[4]

Complete the form using settings similar to the below – ensure you enter YOUR username for the administrator field:

clip_image024_thumb2[4]

Click “OK” when done. The App Catalog site will now create.

Provide payment details to enable the “full” Azure subscription

Within the Office 365 admin area, click the “Azure AD” link:

clip_image025_thumb2[4]

On the next page, click the “Azure subscription” link to start the process of signing-up to Azure:

clip_image027_thumb2[4]

Complete the details on the sign-up page which appears next. You’ll need to verify your identity by providing a phone number to receive a text message or call, and it’s here that you’ll need to provide credit card details. As a reminder, you WON’T be charged for anything unless you explicitly change to a paid subscription – as the page tells you:

clip_image029_thumb2[4]

Once you’re through the process, click “Sign-up”:

clip_image031_thumb2[4]

Your Azure subscription is now creating. You’ll see a screen like the following (though some of the messages may be different) - wait for this process to complete:

clip_image033_thumb2[4]

When the process completes, click the “Start managing my service” button as shown below:

clip_image035_thumb2[4]

Your Azure subscription should now be ready, and you should then be taken into the Azure Portal:

clip_image037_thumb2[4]

Create a development VM in Azure

In this step, we will create a new virtual machine in Azure using the Visual Studio Community 2015 template. Go into the “Virtual machines (classic)” area of the portal, and click the “Add” button:

clip_image039_thumb2[4]

In the Virtual Machines area in the Azure portal, filter for ‘Visual Studio Professional 2015’ and then select the resulting VM from the results.

In the filter box, type “visual studio community 2015” and hit enter. In the list of VM templates which appears, locate the item we want:

clip_image041_thumb2[4]

Select this item from the list. On the next screen, select “Resource Manager” in the dropdown box and then click “Create”:

clip_image042_thumb2[4]

On the next page, enter some details for the virtual machine. Be sure to make a note of the username and password you use: Also be careful with the “Resource Group” setting – you’ll need to create a new Resource Group here (any name is OK). Make sure it then becomes selected in the dropdown:

clip_image043_thumb2[4]

On the next page, select size “A2 - Standard” for the virtual machine size:

clip_image044_thumb2[4]

In the next area, leave the default settings and click “OK”:

clip_image045_thumb2[4]

Click “OK” on the confirmation page:

clip_image046_thumb2[4]

The virtual machine will now start to create – this can take around 20 minutes.

Once the VM has been created, select it in the portal and click on ‘Connect’:

clip_image047_thumb2[4]

This will instantiate the RDP connection. Take care in the RDP box – you’ll need to select “use another account” and be sure to enter the username in the following form:

[machine name]\[username]

This is shown below:

clip_image048_thumb2[4]

Click “OK” once the details are entered. After the security prompt, your RDP session should open and you should now have control of the virtual machine. We now need to perform some configuration steps within the VM to be able to develop SharePoint Add-ins and Office 365 apps.

Setting up IIS

One of the first things we need to do is enable apps to be developed/hosted on http://localhost within the VM. The first step is to enable IIS.

Within the VM, right click on the Start button and select ‘Programs and Features’

clip_image049_thumb2[4]

Select “Turn Windows features on or off”:

clip_image051_thumb2[4]

In the “Add Roles and Features Wizard” which appears, click “Next” until you reach the “Server Roles” page of the dialog. Here, check the box for “Web Server (IIS”) and click “OK” to any prompts which appear:

clip_image053_thumb2[4]

Then, click “Next” until you reach the “Role Services” page for IIS. In this dialog, expand “Application Development” and check the boxes for “ASP.NET 3.5” and “ASP.NET 4.5”:

clip_image055_thumb2[4]

Click “OK” to any prompts which appear. On the confirmation screen, check the box for automatic restarts then click “Install”:

clip_image057_thumb[4]

Wait until process has completed. Once complete you now have IIS running on your VM with ASP.Net enabled.

At this point, restart the machine.

Install Office Development tools

Start Visual Studio 2015 – ensure you right-click and run as administrator:

clip_image058_thumb2[4]

In the dialog which appears, click the “Sign in” button:

clip_image059_thumb2[4]

Enter the details you used for your Office 365 subscription and Azure identity:

clip_image060_thumb2[4]

Accept any prompts which appear until Visual Studio is started.

Once VS has started, close it again. Open a browser window, and navigate to http://aka.ms/OfficeDevToolsForVS2015 - save the file at the prompt, and then run from the download location to run the installer:

clip_image062_thumb2[4]

Accept the prompts which appear, and then wait for the install to complete.

Your virtual machine is now broadly ready for SharePoint Add-in and Office 365 development. Some other steps you may perform are:

  • Create a self-signed certificate to run apps on HTTPS
  • Configure a new IIS website to host apps locally (I prefer this to running IIS Express)

We’ll look at these steps in the next post, “Get started with developing SharePoint Add-ins (apps)”. Until then, happy developing!

3 comments:

Dave said...

Great post Chris! I find myself spinning up a trial O365 tenant on a weekly basis - which is great, except for the barrage of emails I get daily telling me that my subscription is about to expire! :)

I think the reluctance to do this on the part of devs is partly because we've spent the last ten years getting used to the idea that a SharePoint environment is a sacrosanct temple, and once it is running you should guard it jealously and do little to agitate it. SharePoint Online dev lets our environments be fleeting moments that exist for a single purpose and are discarded at will.

By the way, a handy tip for someone looking to avoid the annoying 24 hour wait for the "Custom Script" option to enable... you can force this for a single site collection with the PowerShell "set-sposite" command and the "DenyAddAndCustomizePages" option.

Details: https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f?ui=en-US&rs=en-US&ad=US

Saved my bacon a few times.

Chris O'Brien said...

@Dave,

Good tip, thanks for adding!

COB.

Shreyas said...

As usual Chris, Fantastic post! You hit the nail on the head by addressing the problems that a lot of devs including myself are facing. Learning the ever growing new tech at this pace is not easily supported by companies unless they are product based. But your posts have always kept people like us in the game and this post really takes it to the next level.

Cant thank you enough for the crisp and clear explanation on the steps and cant wait for the next blog.

Cheers!
Shreyas