I had a great chat with John Papa about building Single Page Applications to get a fantastically responsive web UI.
I love continuous deployment to Windows Azure from Team Foundation Service!
Often though we need the flexibility of building and working directly with the WebDeploy package.
Using a precision mocking framework (such as Moq or NSubstitute) encourages developers to write maintainable, loosely coupled code.
Mocking frameworks allow you to replace a section of the code you are about to test, with an alternative piece of code.
For example, this allows you to test a method that performs a calculation and saves to the database, without actually requiring a database.
There are two types of mocking framework.
The Monster Mocker (e.g. Microsoft Fakes or TypeMock)
This type of mocking framework is very powerful and allows replacing code that wasn’t designed to be replaced.
This is great for testing legacy code (tightly coupled code with lots of static dependencies) and SharePoint.
Figure: Bad Example – Our class is tightly coupled to our authentication provider, and as we add each test we are adding *more* dependencies on this provider. This makes our codebase less and less maintainable. If we ever want to change our authentication provider “OAuthWebSecurity”, it will need to be changed in the controller, and every test that calls it.
The Precision Mocker (e.g. Moq)
This mocking framework takes advantage of well written, loosely coupled code.
The mocking framework creates substitute items to inject into the code under test.
Figure: Good Example – The code is loosely coupled. The controller is dependent on an interface, which is injected into the controller via its constructor. The unit test can easily create a mock object and substitute it for the dependency. Examples of this type of framework are Moq and NSubstitute.
The article discusses setting up Azure VMs to run Active Directory, as an alternative to using ‘Windows Azure Active Directory’
Key points in this article
- “To extend AD services such as directory and authentication to VMs in Azure, an architect can now start to include Domain Controllers (DCs) and Read-only DCs (RODCs) in Azure as part of a design or solution.”
- “Microsoft lets you BYON (bring your own network) into Windows Azure, so it’s technically feasible to securely connect on-premise, WAN, and private cloud networks with Azure virtual networks.”
Reasons to have a DC or RODS in Azure
1. Latency: Latency in the AD authentication between on-premise and cloud networks can cause timeout issues (e.g. authentication timeouts) and issues for demanding applications.
2. Resiliency: Having a DC/RODC in Azure ensures the cloud environment continues to function if the connection to the on-premise DCs fail.
3. Cost: “Azure download bandwidth charges are saved by keeping AD-related network traffic such as DNS and LDAP in the cloud. There is no charge for uploads into Azure, so an RODC in Azure, which has no outbound replication channel, will save money compared to having Azure VMs use the Azure virtual network for all AD traffic.”
4. You need a stand-alone AD: “A self-contained AD that lives only in your Azure cloud might provide directory and authentication services to elastic clusters or farms of computers that have no need for authentication with an on-premise AD.”
Create an AD site in Windows Azure
- Azure is really just a huge network of VMs. Configuring AD in Azure is almost the same as hosting AD on VMs on-premise….
“general precautions about ensuring AD recoverability when AD is deployed on VMs apply to VMs in Azure.”
- Issues discussed.. dynamically-assigned network addresses, defining subnets
Provision a DC with the Azure data disk type
- Important details about provisioning a DC:
o “You must add an additional disk to the Azure VM that will be a DC, before running DCPROMO. This second disk must be of the “data” type, not the “OS” type. The C: drive of every Azure VM is of the “OS disk” type, which has a write cache feature that cannot be disabled. Running a DC with the SYSVOL on an Azure OS disk is not recommended and could cause problems with AD.”
o “This means you must not perform a default installation of DCPROMO on an Azure VM, but rather you attach a data disk, then run DCPROMO and locate AD files such as SYSVOL on the data disk, not the C: drive. This link at Microsoft has checklists to add an Azure VM data disk or attach an empty data disk:
Alternative Option: “Windows Azure Active Directory” product
- “Windows Azure Active Directory” – is a separate product
- It is an alternative to setting up Azure VMs to run AD (what we are talking about in this article)
- It is an outsourced AD that lives completely and only in the cloud.
- It appeals to Microsoft Office 365, Dynamics CRM Online, and Windows InTune customers
Follow Up Reading
- Guidelines for Deploying Windows Server Active Directory on Windows Azure Virtual Machines
- BYON into the public cloud with Azure Virtual Networks
I had a conversation today with a lead developer who was working with a team who couldn’t get the hang of not checking in bad code. To resolve the issue, he implemented Gated Checkins. He asked me to check out some the code and I was happy to, right up until I had to do a few checkins. The following are my subsequent thoughts on the matter.
Gated checkins are used to stop developers from checking in bad code and breaking the build.
This does not contribute to high functioning teams, and instead masks, or even creates dysfunction.
To illustrate lets look at a couple of examples.
In the retro the team decides to turn gated checkins on because Jonny and Sue keep breaking the build.
The build doesn’t get broken any more, because Jonny and Sue now have to fix their code before they check it in.
This doesn’t mean that Jonny and Sue are writing better code, it just means that they are not checking in code that breaks the build.
Gated checkins will not improve their skill level, change their attitude or improve the quality of their code.
The development ninjas on the team are proud of their code, and check in several times per day.
Because the gated checkin takes 10 minutes their workflow is impacted.
They resent Jonny and Sue for having to work this way.
Gated Checkins mask the dysfunction on the team, and introduce impediments to the high performers.
Example – Gated Checkins mask dysfunction
In the retro the team discusses the fact that the build is often broken.
After a round table discussion about becoming better programmers and building better quality software, the team decides to the following guidelines:
1. The team will all run build notifications so that everyone knows when, and by whom the build is broken.
2. If someone needs help with solving a problem, they are going to feel good about asking for help early, and learning something new in the answer.
3. If someone is asked for help, they will gladly share their knowledge to ensure that the quality of the project is maintained ,and the team help each other to become better developers.
4. Before checking in, the devs will compile and run all tests. **
5. If someone checks in and does break the build, they will call out to all members of the team that the build is broken so that no-one gets latest. They will fix the build IMMEDIATELY, and then call out again when it is fixed.
(Some teams have a rule that if you break the build three times you have to shout coffee / lunch).
6. The team agrees that you don’t go home if the build isn’t green.
If it comes to the end of the day and you are not sure your code will not break the build – do not checkin. Create a shelveset and resolve the issue properly the next day.
If you have checked in, the build is broken, and you cannot fix it before going home, you must email all devs on the team, and the product owner with an explanation.
7. The status of the build is reviewed in every daily scrum. Edit: Gerard correctly pointed out that this is bad Scrum.
Example – The whole team should be constantly aware and invested in the status of the build, the quality of the software and in encouraging each other to better developers.
** I actually don’t follow this rule when working on small teams of awesome devs, who write code against tests and checkin frequently.
Instead I encourage the process to be
- checkin 4-5 times a day
- write lots of tests
- if the tests that you are working against pass- checkin and let the build server do a full compile and run all the tests
- if you have broken the build, call it out, fix it immediately and then call it out again.
This is the most productive way for small teams of awesome developers to produce great code… and it’s fun !
Microsoft has released the ability to easily create a Virtual Machine hosted on Azure
Figure: I can’t quite believe how easy it is to ‘Quick Create’ a new Virtual machine. It literally takes a few minutes to have a Windows Server running in the cloud.
Figure: Alternatively you create a Windows or LINUX VM from selection of images in the Gallery. You can also add your own images to the gallery. This process only takes marginally longer than Quick Create, but gives you more options for customization.
Situations where I love Azure VMs
1. Have a Dev box in the cloud
I have an Azure VM with Visual Studio 2012 and SQL Express 2012 on it.
I keep it at an Extra-Small instance for most of the month ($15/month) and ramp it up to a Large/Extra Large instance when I want to work on it.
Figure: Changing the size of the VM is amazingly simple. Log onto the portal, choose an option from the drop down and click Save. Wait a few minutes and log back in.
Figure: I love that I can connect to my Dev VM from anywhere…. Including my iPad
Figure: Running Visual Studio 2012 on Azure from the iPad (the Apple Wireless keyboard nearly makes this workable)
Would I pay $233 per month to leave it as a large instance and make this my full time dev environment – No.
2. Training machines in the cloud.
Similar to the above situation, it was great to be able to spin up 24 Medium instances to have people do labs on at the Enterprise MVC course.
Attendees were given RPD credentials and logged into their own Azure VM.
The alternatives we considered were
- Each attendee downloads and installs Visual Studio 2012 RC and SQL Express 2012 on their laptops
- Each attendee brings a laptop running a 64 bit OS capable of running a VM, and downloads a VM onto their machine.
The issues that we had with using Azure VMs to run training machines were
- Medium VMs were a bit slow – next time we should use Large
- RPD is not heavy, but we did have issues in some offices with the number of people connected to the available wireless routers
- The network connection died at one training venue. Luckily this happened late in the afternoon when most people had completed the lab exercises
- Some VMs would simply fail to provision. The VM feature is not actually released yet and I’m sure this will be addressed
- Provisioning the machines takes some time because they have to be done synchronously. i.e. Create a new VM, wait for it to finish provisioning and then create the next one.
This is something we will look at automating ourselves, but it would be great to have the functionality available on the MS portal.
For a single day of training with 24 Medium VMs this cost about $50. This is incredible value.
Situations where I do not think Azure VMs are the answer
1. Hosted Full Time Server
For a full time machine of reasonable size you are looking at $335 or $671 per month. I doubt this is cost effective.
I’d be interested to hear from some Sys Admin types about what they believe their on-premise servers cost them per month.
Azure VM Pricing Summary
|Preview Prices||cores||memory||per hr||per day||per month|
|Extra Small||Shared||768Mb||$ 0.013||$ 0.31||$ 9.49|
|Small||1||1.75 GB||$ 0.080||$ 1.92||$ 58.40|
|Medium||2||3.5 GB||$ 0.160||$ 3.84||$ 116.80|
|Large||4||7 GB||$ 0.320||$ 7.68||$ 233.60|
|Extra Large||8||14 GB||$ 0.640||$ 15.36||$ 467.20|
|Figure: This is the pricing while the VM feature is in preview|
|Release Prices||cores||memory||per hr||per day||per month|
|Extra Small||Shared||768Mb||$ 0.020||$ 0.48||$ 14.60|
|Small||1||1.75 GB||$ 0.115||$ 2.76||$ 83.95|
|Medium||2||3.5 GB||$ 0.230||$ 5.52||$ 167.90|
|Large||4||7 GB||$ 0.460||$ 11.04||$ 335.80|
|Extra Large||8||14 GB||$ 0.920||$ 22.08||$ 671.60|
|Figure: This is the pricing after the VM Feature is released|
Everyone knows about my deep love for Azure. Most people also know it’s a bit of a love-hate relationship.
It’s so full of promise, but everything turns out to be a bit harder to implement in practice than it should be… until now.
Figure: In the Azure portal, go to your Account settings, then to the Preview Features tab, and select ‘Try it now’ next to Web Sites
Figure: Navigate back to the Portal, click ‘New’, select ‘Web Site’ and then ‘From Gallery‘
Figure: A host of great Apps are available. I’m pushed for time and this is a distraction from writing the course I am delivering tomorrow so I will choose WordPress as I am familiar with it.
Figure: Choose the DNS prefix that you wish to use, select your nearest region and click Next
Figure: Enter a database name, select the region, agree to the conditions and click next
Figure: Complete the WordPress installation form and click ‘Install’
Figure: And you are done. I love this confirmation message.
Figure: And as easy as that I am hosting my own WordPress blog.
Thank you Azure.
And Yes. This blog post took three times longer to create than the new site that I am going to have to move it to.
Azure transactions are CHEAP. You get tens of thousands for just a few cents. What is dangerous though is that it is very easy to have your application generate hundreds of thousands of transactions a day.
Every call to Windows Azure Blobs, Tables and Queues count as 1 transaction. Windows Azure diagnostic logs, performance counters, trace statements and IIS logs are written to Table Storage or Blob Storage.
If you are unaware of this, it can quickly add up and either burn through your free trial account, or even create a large unexpected bill.
Note: Azure Storage Transactions do not count calls to SQL Azure.
Ensure that Diagnostics are Disabled for your web and worker roles
Having Diagnostics enabled can contribute 25 transactions per minute, this is 36,000 transactions per day.
To Do: Confirm that this is per Web/Worker Role
Figure: Check the properties of your web and worker role configuration files
Figure: Disable diagnostics for both roles
Disable IntelliTrace and Profiling
Figure: When publishing, ensure that IntelliTrace and Profiling are both disabled.
Search bots crawling your site to index it will lead to a lot of transactions. Especially for web ‘applications’ that do not need to be searchable, use Robot.txt to save transactions.
Figure: Place robots.txt in the root of your site to control search engine indexing
When deploying to Azure, the deployment package is loaded into the Storage Account. This will also contribute to the transaction count.
If you have enabled continuous deployment to Azure, you will need to monitor your transaction usage carefully.