Scott Hanselman

Deploying TWO websites to Windows Azure from one Git Repository

February 4, '14 Comments [13] Posted in Azure
Sponsored By

Deploying to Windows Azure is very easy from Git. I use the Azure Cross-Platform Command Line (open source on github, written in node) that I get from npm via "npm install azure-cli --g" to make the sites.

When you make a new site with the Azure command line, you'll usually do this:

azure site create --location "West US" MyFirstSite --git

And the tool will not only make the site, but also add a git remote for you, something like https://username@MyFirstSite.scm.azurewebsites.net:443/MyFirstSite.git. When you push to that git remote, Azure deploys the site. You can git push sites with PHP, node, ASP.NET, and Python.

Two Deployments in Azure using Git

You may have multiple remotes with your git repository, of course:

C:\MyCode>git remote show
azure
origin

When you push a folder with code to Azure via Git, unless you're pushing binaries, Azure is going to compile the whole thing for you when it gets pushed. It will restore npm modules or restore NuGet packages, and then build and deploy your app.

If your repository has a lot of .NET projects, you usually only want one project to be the actual deployed website, so you can add a .deployment file to specify which project contains website you're git deploying:

[config]
project = WebProject/MyFirstSiteWebProject.csproj

However, in lieu of a .deployment file, you can also set an application configuration setting with the Azure Portal to to the same thing.

Setting Kudu Projects with Config options

Or, of course, set the configuration values for each site using the Azure Command Line:

c:\MyCode>azure site config add Project=WebProject/MyFirstSiteWebProject.csproj [sitename]

What's nice about setting the "Project" setting via site configuration rather than via a .deployment file is that you can now push the same git repository containing two different web sites to two remote Azure web sites. Each Azure website should have a different project setting and will end up deploying the two different sites.

Git Deploying from one Repo to two separate Azure Web Sites

I do this by setting the git remotes manually like this, using the correct git remote URLs I get from the Azure Portal:

C:\MyCode> git remote add azureweb1 https://scott@website1.scm.azurewebsites.net:443/website1.git
C:\MyCode> git remote add azureweb2 https://scott@website2.scm.azurewebsites.net:443/website2.git
C:\MyCode> git remote show
azureweb1
azureweb2
origin
C:\MyCode> git push azureweb1 master

I have a number of solutions with two or more web sites, or in one case, a web site I want separate from my web api, and I deploy them just like this.

Hope this helps!


Sponsor: Big Thanks to Aspose for sponsoring the blog this week! Aspose.Total for .NET has all the APIs you need to create, manipulate and convert Microsoft Office documents and a host of other file formats in your applications. Curious? Start a free trial today.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Fixed: The Synology NAS with Plex Server and mismatched version numbers

February 4, '14 Comments [16] Posted in Bugs | Musings
Sponsored By

I am a HUGE fan of Plex. Plex is a server you run combined with both a great HTML5 web app and some awesome native clients. Plex has clients for iOS, Windows Store, Windows Phone, and on and on. Best yet, the Plex Server can run not only on your spare computers, but also NAS (Network Attached Storage) devices like Synology, Netgear, Drobo, and more.

Last year, Plex came to the Synology DiskStation. I have a Synology 1511+ NAS and run everything on it from Minecraft Servers to Plex to using it as a giant 5TB NAS to storing my Time Machine backups and Windows 8 File History. I also run CrashPlan headless on my Synology.

Synology has an ersatz App Store that allows you to easily install all sorts of stuff to your Synology NAS, like phpBB, Plex, Git, and more.

Plex installed on Synology

However, I personally (and others) have found this feed of packages to be either updated not very often, or when it is updated, versions don't line up.

If I can be slightly critical of Plex for a moment, they are fairly aggressive about keeping their client and server protocol versions in line. This means if you aren't keeping your Plex Server reasonably up to date, one day you'll startup your iPad Plex app or Windows Plex app and be told that server version is too old. It's a little jarring.

The issue for me happens when I go to the Synology to update and there's no new update. So the client is saying "you need version x+2" and all I see on the Synology feed is version x.

Plex example on a Microsoft Surface RT with Windows 8

Here's the gotcha, and why I'm writing this up for you. You can use the Manual Install option (as seen in the top picture) then visit https://plex.tv/downloads and manually upload the .SPK file for Plex to your Synology server.

If you don't uninstall Plex first - that's the one that you install from Synology's feed originally - then you can get yourself into some very weird versioning situations where Plex thinks one version is running and the Synology thinks another as seen in the screenshot below.

Plex Version Numbers not lining up

This has been discussed in the forums for almost a year now with no clear answer or solution.

Again, here's what I did:

  • Uninstall Plex from the Synology Package Manager
  • Download Plex from https://plex.tv/downloads
  • Use Manual Install to install the new SPK to Synology

I hope this helps someone. Be sure to check out Plex, it's a joy.


Sponsor: Big Thanks to Aspose for sponsoring the blog this week! Aspose.Total for .NET has all the APIs you need to create, manipulate and convert Microsoft Office documents and a host of other file formats in your applications. Curious? Start a free trial today.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Here's 10 things I did before I wrote this blog post title. What happened next will shock you.

January 31, '14 Comments [31] Posted in Musings
Sponsored By

What a crap title, eh? Just the worst. But this kind of linkbait garbage is rampant on our internet - that's yours and my internet, people - and we're promoting their chicanery by spreading their links.

This came to a head for me yesterday when a video started going viral on the social web AGAIN. I say AGAIN because it was the same darn video from 5 years ago, just with a new title. Seriously, a totally unrelated "viral" site made up a new title, called it an article, then embedded the video with their ads everywhere, then (I presume) went to their bosses and say "my stuff generated x PV (page views) this week."

Step 4. PROFIT

I partially blame BuzzFeed, but every once in a while they have a decent article. Upworthy is another, disguising their stealing with an "inspirational spin." One that is the worst is ViralNova - find them yourself, no link from me. Sites like these started this style of hanging headline:

  • It Might Seem Like A Normal Temple From The Outside. But Go Inside And… AHHHH!
  • This Is The Most Unique Sunrise You’ll Ever See. Guaranteed.
  • A 12 Year-Old Boy Wrote The Perfect Advice To Understand Women. This Is Priceless.
  • You’ll Have No Idea What You’re Seeing In These 20 Photos. But Look A Little Closer…

How is this a business? Apparently mining for Page Views is more profitable than mining for Bitcoin.

And now this madness is spreading to CNN. That's supposed to be a real news site, folks.

These are custom designed to prey on our base human need to always be seeing new crap. It's drug pushing.

Many sites declare their content "curated" and pull it (most often without explicit permission) from elsewhere. They pull so much from the original site that there's usually no reason to visit the original site! One article recently had 20 high resolution pictures lifted from elsewhere. Buried in the the post it said "via so-in-so" so I visited there, if only to give my page view to the original author and some how cleanse myself. I counted the photos while I was there. There where 20 images. They had reblogged them all.

These are entire "media companies" that have turned reblogging into an art. Reblogging is not journalism. It's not even nice. It's not appreciated, it's not appropriate, and it's not kind.

When you blog, think about what it really means to curate. Consider the Curator's Code. When you use something, give attribution or a hat tip. Confused or not sure if you should use something, ask. Just email them, explain what you want to do, and ask.

There's even Chrome extensions like @snipeyhead's "Downworthy" that will replace the text in headlines like these with more appropriate text.

Please, don't start a multimillion pageview media conglomerate based on copy-pasting other people's hard work combined with deceptive copywriting.

Reject them. I reject them. Will the beginning of the end start on the Dark and Evil Side of the Internet or will it sneak up on us slowly with harmless titles like "The 26 Craziest Crimes That Involve Taco Bell." OMG! I have to click.

image


Sponsor: Thanks to Red Gate for sponsoring Blog Feed this week! Want Easy release management? Deploy your SQL Server databases in a single, repeatable process with Red Gate's Deployment Manager. There's a free Starter edition, so get started now!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Why isn't People-Centric UI Design taking off?

January 27, '14 Comments [86] Posted in Musings
Sponsored By

NOTE: This post is just speculation and brainstorming. I'm not a UX expert by any means, although I have worked in UI testing labs, run A/B tests, yada yada yada. I dabble. Also, I work for Microsoft, but on the Web and in Open Source. I use an iPhone. Those facts don't affect my ramblings here.

Screenshot from my Windows 3.1 Virtual MachineiPhone screenshot from Flickr User philozopher used under CC

I'm just a little disappointed that 30 years later (longer of course, if you consider Xerox Alto and before, but you get the idea) and we're still all looking at grids of icons. But not just icons, icons are great. It's that the icons still represent applications. Even on my iPhone or iPad I can't have an icon that represents a document. The closest I can get is to add a URL from Mobile Safari.

After Windows 3.1, Microsoft made a big deal about trying to say that Windows was a "document-centric operating system." OS/2 Warp did similarly, except object-centric, which was rather too meta for the average business user. Bear with me here, this is old news, but it was a big deal while we were living it. They kept pushing it up through Windows 98.

This document-centric approach is reflected in a number of Windows 98 features. For example, you can place new blank documents on the Desktop or in any folder window. You can access documents via the Documents menu on the Start menu. You can click a file icon and have its associated application open it, and you can define actions to be taken on a file and display those actions as options in the context menu

Today on the desktop we take all this for granted. Ubuntu, OS X, Windows all know (for the most part) how a document was created and let us open documents in associated programs. iOS is starting to get similar document-centric abilities, although it appears Open In is limited to 10 apps.

In Windows Phone and Windows 8+ I can pin People to the Start Screen. It's a killer feature that no one talks about. In fact, Nokia recently tweeted a screenshot of a 1080p Windows Phone (I've been testing the this last month myself) and I think they made a mistake here. Rather than pinning People, Faces, Groups, Friends, Family, Co-Workers, etc, they shrunk down a bunch of ordinarily good looking icons to their most unflattering to see how many they could fit on the screen.

(Plus they have 19 Updates pending, which I just find annoying.)

Here's mine next to theirs, just to contrast. Now, far be it from me to tell someone how to personalize their phone, I'm just trying to show that it doesn't have to be cartoonish.

What I'm really interested in is why do we, as humans, find App Centric interfaces more intuitive than People Centric ones?

Be5xQ4aCMAABrmy wp_ss_20140127_0006

The "story" around People Centric is that you don't think "go to twitter and tweet my friend" or "go to Skype and call my friend," instead you click a picture of your friend and then contact them in any possible way using any enlisted app from there.

For example, if I search my Windows machine for "Scott Guthrie" I get this (Scott is lousy about keeping his pictures up to date.)

image

You can see from here I can Email, Call, Facebook, Skype (if he had Skype), or get a map to his house. All his actual accounts, Twitter, Facebook, etc are linked into one Scott Guthrie Person.

Screenshot (56)

It works great on the phone, where I'm more likely to do more than just email. Note at the bottom there's a chain with a number showing that my wife has 6 accounts (Google, Hotmail, Facebook, Skype, etc) that are all linked into one Contact.

image

Folks that use Windows Phone mostly know about these features, and the hardcore users I know pin people to Start. On the desktop, though, I never see this. I wonder why. I am surprised that in a people focused world of social networks that elevating our friends, family and loved ones to be at least peers with notepad.exe would have happened by now.

What do you think, Dear Reader? Have you given this some thought in your interfaces?


Sponsor: Thanks to Red Gate for sponsoring Blog Feed this week! Want Easy release management? Deploy your SQL Server databases in a single, repeatable process with Red Gate's Deployment Manager. There's a free Starter edition, so get started now!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Introducing Windows Azure WebJobs

January 23, '14 Comments [42] Posted in Azure
Sponsored By

I'm currently running 16 web sites on Windows Azure. I have a few Virtual Machines, but I prefer to run things using "platform as a service" where I don't have to sweat the underlying Virtual Machine. That means, while I know I can run a Virtual Machine and put "cron" jobs on it, I'm less likely to because I don't want to mess with VMs or Worker Roles.

There are a few ways to run stuff on Azure, first, there's IAAS (Infrastructure as a Service) which is VMs. Then there's Cloud Applications (Cloud Services) where you can run anything in an Azure-managed VM. It's still a VM, but you have a lot of choice and can run Worker Roles and background stuff. However, there's a lot of ceremony if you just want to run your small "job" either on a regular basis or via a trigger.

Azure Explained in one Image

Looking at this differently, platform as a service is like having your hotel room fixed up daily, while VMs is more like managing a house yourself.

Azure Explained in one Image

 

As someone who likes to torch a hotel room as much as the next person, this is why I like Azure Web Sites (PAAS). You just deploy, and it's done. The VM is invisible and the site is always up.

However, there's not yet been a good solution under web sites for doing regular jobs and batch work in the background. Now Azure Web Sites support a thing  called "Azure WebJobs" to solve this problem simply.

Scaling a Command Line application with Azure WebJobs

When I want to do something simple - like resize some images - I'll either write a script or a small .NET application. Things do get complex though when you want to take something simple and do it n times. Scaling a command line app to the cloud often involves a lot of yak shaving.

Let's say I want to take this function that works fine at the command line and run it in the cloud at scale.

public static void SquishNewlyUploadedPNGs(Stream input, Stream output)
{
var quantizer = new WuQuantizer();
using (var bitmap = new Bitmap(input))
{
using (var quantized = quantizer.QuantizeImage(bitmap))
{
quantized.Save(output, ImageFormat.Png);
}
}
}

WebJobs aims to make developing, running, and scaling this easier. They are built into Azure Websites and run in the same VM as your Web Sites.

Here's some typical scenarios that would be great for the Windows Azure WebJobs SDK:

  • Image processing or other CPU-intensive work.
  • Queue processing.
  • RSS aggregation.
  • File maintenance, such as aggregating or cleaning up log files. 
  • Other long-running tasks that you want to run in a background thread, such as sending emails.

WebJobs are invoked in two different ways, either they are triggered or they are continuously running. Triggered jobs happen on a schedule or when some event happens and Continuous jobs basically run a while loop.

WebJobs are deployed by copying them to the right place in the file-system (or using a designated API which will do the same). The following file types are accepted as runnable scripts that can be used as a job:

  • .exe - .NET assemblies compiled with the WebJobs SDK
  • .cmd, .bat, .exe (using windows cmd)
  • .sh (using bash)
  • .php (using php)
  • .py (using python)
  • .js (using node)

After you deploy your WebJobs from the portal, you can start and stop jobs, delete them, upload jobs as ZIP files, etc. You've got full control.

A good thing to point out, though, is that Azure WebJobs are more than just scheduled scripts, you can also create WebJobs as .NET projects written in C# or whatever.

Making a WebJob out of a command line app with the Windows Azure WebJobs SDK

WebJobs can effectively take some command line C# application with a function and turn it into a scalable WebJob. I spoke about this over the last few years in presentations when it was codenamed "SimpleBatch." This lets you write a simple console app to, say, resize an image, then move it up to the cloud and resize millions. Jobs can be triggered by the appearance of new items on an Azure Queue, or by new binary Blobs showing up in Azure Storage.

NOTE: You don't have to use the WebJobs SDK with the WebJobs feature of Windows Azure Web Sites. As noted earlier, the WebJobs feature enables you to upload and run any executable or script, whether or not it uses the WebJobs SDK framework.

I wanted to make a Web Job that would losslessly squish PNGs as I upload them to Azure storage. When new PNGs show up, the job should automatically run on these new PNGs. This is easy as a Command Line app using the nQuant open source library as in the code above.

Now I'll add the WebJobs SDK NuGet package (it's prerelease) and Microsoft.WindowsAzure.Jobs namespace, then add [BlobInput] and [BlobOutput] attributes, then start the JobHost() from Main. That's it.

using Microsoft.WindowsAzure.Jobs;
using nQuant;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
JobHost host = new JobHost();
host.RunAndBlock();
}

public static void SquishNewlyUploadedPNGs(
[BlobInput("input/{name}")] Stream input,
[BlobOutput("output/{name}")] Stream output)
{
var quantizer = new WuQuantizer();
using (var bitmap = new Bitmap(input))
{
using (var quantized = quantizer.QuantizeImage(bitmap))
{
quantized.Save(output, ImageFormat.Png);
}
}

}
}
}

CONTEXT: Let's just step back and process this for a second. All I had to do was spin up the JobHost and set up a few attributes. Minimal ceremony for maximum results. My console app is now processing information from Azure blob storage without ever referencing the Azure Blob Storage API!

The function is automatically called when a new blob (in my case, a new PNG) shows up in the input container in storage and the Stream parameters are automatically
"bound" (like Model Binding) for me by the WebJobs SDK.

To deploy, I zip up my app and upload it from the WebJobs section of my existing Azure Website in the Portal.

image

Here it is in the Portal.

image

I'm setting mine to continuous, but it can also run on a detailed schedule:

12schdmonthsonpartweekdaysoccurences

I need my WebJob to be told about what Azure Storage account it's going to use, so from my Azure Web Site under the Connection Strings section I set up two strings, one for the AzureJobsRuntime (for logging) and one for AzureJobsData (what I'm accessing). 

image

For what I'm doing they are the same. The connection strings look like this:

DefaultEndpointsProtocol=https;AccountName=hanselstorage;AccountKey=3exLzmagickey

The key here came from Manage Access Keys in my storage account, here:

image

In my "Hanselstorage" Storage Container I made two areas, input and output. You can name yours whatever. You can also process from Queues, etc.

image

Now, going back to the code, look at the parameters to the Attributes I'm using:

public static void SquishNewlyUploadedPNGs(           
[BlobInput("input/{name}")] Stream input,
[BlobOutput("output/{name}")] Stream output)

There's the strings "input" and "output" pointing to specific containers in my Storage account. Again, the actual storage account (Hanselstorage) is part of the connection string. That lets you reuse WebJobs in multiple sites, just by changing the connection strings.

There is a link to get to the Azure Web Jobs Dashboard to the right of your job, but the format for the URL to access is this: https://YOURSITE.scm.azurewebsites.net/azurejobs. You'll need to enter your same credentials you've used for Azure deployment.

Once you've uploaded your job, you'll see the registered function(s) here:

image

I've installed the Azure SDK and can access my storage live within Visual Studio. You can also try 3rd party apps like Cloudberry Explorer. Here I've uploaded a file called scottha.png into the input container.

image

After a few minutes the SDK will process the new blob (Queues are faster, but blobs are checked every 10 minutes), the job will run and either succeed or fail. If your app throws an exception you'll actually see it in the Invocation Details part of the site.

image

Here's a successful one. You can see it worked (it squished) because of the number of input bytes and the number of output bytes.

image

You can see the full output of what happens in a WebJob within this Dashboard, or check the log files directly via FTP. For me, I can explore my output container in Azure Storage and download or use the now-squished images. Again, this can be used for any large job whether it be processing images, OCR, log file analysis, SQL server cleanup, whatever you can think of.

Azure WebJobs is in preview, so there will be bugs, changing documentation and updates to the SDK but the general idea is there and it's solid. I think you'll dig it.

Related Links


Sponsor: Big thanks to combit for sponsoring the blog feed this week! Enjoy feature-rich report designing: Discover the reporting tool of choice for thousands of developers. List & Label is an award-winning component with a royalty-free report designer. Free trial!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.