Category Archives: Uncategorized

Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

Have you ever gotten the error:

Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

And your string looks valid?   Case in point:

Guid.Parse(“a2d979b0-26b5-11e7-be4d-cd02cf813brd”)
‘Guid.Parse(“a2d979b0-26b5-11e7-be4d-cd02cf813brd”)’ threw an exception of type ‘System.FormatException’
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233033
HelpLink: null
InnerException: null
Message: “Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).”
Source: “mscorlib”
StackTrace: ” at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException)\r\n at System.Guid.TryParseGuidWithDashes(String guidString, GuidResult& result)\r\n at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)\r\n at System.Guid.Parse(String input)”
TargetSite: {Void SetFailure(ParseFailureKind, System.String, System.Object, System.String, System.Exception)}

So what gives?  The Guid appears valid in format:

—–8—– – —4— – —4— —4— ——–12——–

a2d979b0 – 26b5 – 11e7 – be4d – cd02cf813brd

If you look at the definition of the Guid type in .NET:

https://msdn.microsoft.com/en-us/library/96ff78dc(v=vs.110).aspx

Type: System.String

A string that contains a GUID in one of the following formats (“d” represents a hexadecimal digit whose case is ignored):

32 contiguous digits:

dddddddddddddddddddddddddddddddd

-or-

Groups of 8, 4, 4, 4, and 12 digits with hyphens between the groups. The entire GUID can optionally be enclosed in matching braces or parentheses:

dddddddd-dddd-dddd-dddd-dddddddddddd

-or-

{dddddddd-dddd-dddd-dddd-dddddddddddd}

-or-

(dddddddd-dddd-dddd-dddd-dddddddddddd)

-or-

Groups of 8, 4, and 4 digits, and a subset of eight groups of 2 digits, with each group prefixed by “0x” or “0X”, and separated by commas. The entire GUID, as well as the subset, is enclosed in matching braces:

{0xdddddddd, 0xdddd, 0xdddd,{0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd}}

All braces, commas, and “0x” prefixes are required. All embedded spaces are ignored. All leading zeros in a group are ignored.

The digits shown in a group are the maximum number of meaningful digits that can appear in that group. You can specify from 1 to the number of digits shown for a group. The specified digits are assumed to be the low-order digits of the group.

So, whats wrong with my string?

a2d979b0-26b5-11e7-be4d-cd02cf813brd

A GUID is a 16-byte (128-bit) number, typically represented by a 32-character hexadecimal string. A GUID (in hex form) need not contain any alpha characters, though by chance it probably would. If you are targeting a GUID in hex form, you can check that the string is 32-characters long (after stripping dashes and curly brackets) and has only letters A-F and numbers.

So, there is the problem, a Guid isn’t just a random string of Digits and Characters, it’s a string representation of a 128 bit number!

Make sure you only have A-F and 0-9!

What else can go wrong?  Check out this Guid:

“E6F85AE0‐F479‐4E98‐9287‐98F7E62BA083”

When parsing it I get:

Guid.Parse(“E6F85AE0‐F479‐4E98‐9287‐98F7E62BA083”)
‘Guid.Parse(“E6F85AE0‐F479‐4E98‐9287‐98F7E62BA083”)’ threw an exception of type ‘System.FormatException’
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233033
HelpLink: null
InnerException: null
Message: “Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).”
Source: “mscorlib”
StackTrace: ” at System.Guid.TryParseGuidWithNoStyle(String guidString, GuidResult& result)\r\n at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)\r\n at System.Guid.Parse(String input)”
TargetSite: {Boolean TryParseGuidWithNoStyle(System.String, GuidResult ByRef)}

The Guid Seems ok,

“E6F85AE0‐F479‐4E98‐9287‐98F7E62BA083”

All the characters are A-F and 0-9, what else could be wrong?

Try converting your string to its ASCII equivalent:

http://onlinecalculators.brainmeasures.com/Conversions/StringtoAsciiCalculator.aspx

The result:

ASCII: 34 69 54 70 56 53 65 69 48 NULL 70 52 55 57 NULL 52 69 57 56 NULL 57 50 56 55 NULL 57 56 70 55 69 54 50 66 65 48 56 51 34

What are those NULLS?

Look at the HEX:

22 45 36 46 38 35 41 45 30 1 46 34 37 39 1 34 45 39 38 1 39 32 38 37 1 39 38 46 37 45 36 32 42 41 30 38 33 22

Retype the string manually (DONT COPY/PASTE!)

“E6F85AE0-F479-4E98-9287-98F7E62BA083”

Now get its ASCII

34 69 54 70 56 53 65 69 48 45 70 52 55 57 45 52 69 57 56 45 57 50 56 55 45 57 56 70 55 69 54 50 66 65 48 56 51 34

(No more NULLS)

and HEX:

22 45 36 46 38 35 41 45 30 2D 46 34 37 39 2D 34 45 39 38 2D 39 32 38 37 2D 39 38 46 37 45 36 32 42 41 30 38 33 22

See the difference?

22 45 36 46 38 35 41 45 30 1 46 34 37 39 1 34 45 39 38 1 39 32 38 37 1 39 38 46 37 45 36 32 42 41 30 38 33 22 

22 45 36 46 38 35 41 45 30 2D 46 34 37 39 2D 34 45 39 38 2D 39 32 38 37 2D 39 38 46 37 45 36 32 42 41 30 38 33 22

Its the hyphens!  They are actually a different character!

This is a common issue on the web!  Sometimes when encoding values from Unicode, ASCII, UTF-8, etc, characters can get transposed.

So, next time you run into some “weirdness” with strings and Guids, Don’t give up! think outside the box!

“No App Service Environments in this subscription”

Adding an application to an Azure Application Service Environment (ASE) is a pretty straight-forward operation, but sometimes you will get:

“No App Service Environments in this subscription”

What does this mean?  Why isn’t the App Service Environment in the list?

App Service Environments are a premium feature of the Microsoft Cloud.   It provides a fully isolated and dedicated environment for securely running Azure App Service apps at high scale, including Web Apps, Mobile Apps, and API Apps.

App Service Environments scale differently than most apps in Azure.  First, the ASE itself defines a set of worker pool instances:

The pool instance counts represent the number of physical resources available in each worker pool in your ASE.

If you click on your ASE’s main blade, then select Worker Pools.  Then choose a worker pool.  You can see the resources allocated in the pool:

Notice the “Workers Available” is 0.  Because of this I’m unable to add any new applications or App Service Plans to the ASE.  You first need to increase the scale of the pool to accommodate additional resources.

Here I’ve increased the Worker pool 1 Instance Count from 2 to 3.

At the time of this writing, ASE scale operations take several hours to complete. You will see this notification while the scale operation is in progress.

Once completed.  You now have an extra instance available in your worker pool to add an additional App Service Plan and Application.

You can see the App Service Environment is now available in the Location drop down, now that there is additional capacity in the Worker Pool for the App Service Plan.

How to add a new App Service Plan (ASP) to an App Service Environment (ASE)

An Azure App Service Environment is a premium tier offering for high scale applications that can isolate your application on a custom virtual network and give you more control over the compute resources allocated to your applications.

To increase the scale and control over the Applications running in your ASE, you can add additional App Service Plans to your ASE.

When you first work with ASE’s however, it doesn’t seem obvious how to add additional service plans to your ASE.

When creating an additional App Service Plan, you have to have enough instances in the ASE worker pool before you are allowed to create the ASP.

As you can see below, I can’t select my ASE from the location list:

When you want to add an additional ASP to your ASE, you select the ASE itself as the location for the creation of the ASP.

Without enough instances in your ASE worker pool, the ASE is not available in the Location drop down when creating a new ASP.

First you need to increase the instance count in your ASE to provide additional instances for your ASP to manage.

Increase the Instance count of your Front End or Worker Pools.  This scale operation will take several hours to complete.

Once the scale operation is completed, you can now create additional App Service plans in your ASE.

Hope this helps you, It drove me crazy trying to figure this out the first few times I used ASE’s

SQL Server vs Azure SQL

Recently, I helped a customer with a seasonal website that was having performance problems after moving it to Azure.  Last year the site was hosted on-premise and ran fine, but this year he moved the application to Azure and just “felt like” it was running slower.

I did a basic analysis of his Azure footprint.

Redis Cache, Azure SQL Server, 3 WebApps, 2 storage accounts.  The customer has ramped Azure SQL up to the P4 pricing tier to try and increase DB performance.

At first I considered the underlying storage account.  When running SQL Server on a Virtual Machine (Iaas) the type of storage account you choose can significantly affect performance!

Microsoft warns:

Standard Storage has varying latencies and bandwidth and is only recommended for dev/test workloads. Production workloads should use Premium Storage.

Looking at the customer’s storage accounts they were all standard!

But wait, the customer is using Azure SQL, NOT Sql on a VM.  So does the storage matter?  Not with Sql Azure…

3 tiers of service are available:

Service tier Target workloads
Basic Best suited for a small database, supporting typically one single active operation at a given time. Examples include databases used for development or testing, or small-scale infrequently used applications.
Standard The go-to option for most cloud applications, supporting multiple concurrent queries. Examples include workgroup or web applications.
Premium Designed for high transactional volume, supporting many concurrent users and requiring the highest level of business continuity capabilities. Examples are databases supporting mission critical applications.

Sql Azure measures performance in DTUs – Database Transaction Units

You can customize your instance depending on your desired performance level.

Basic service tier

Service tier Basic
Max DTUs 5
Max database size 2 GB
Max in-memory OLTP storage N/A
Max concurrent workers 30
Max concurrent logins 30
Max concurrent sessions 300

Standard service tier

Service tier S0 S1 S2 S3
Max DTUs 10 20 50 100
Max database Size 250 GB 250 GB 250 GB 250 GB
Max in-memory OLTP storage N/A N/A N/A N/A
Max concurrent workers 60 90 120 200
Max concurrent logins 60 90 120 200
Max concurrent sessions 600 900 1200 2400

Premium service tier

Service tier P1 P2 P4 P6 P11 P15
Max DTUs 125 250 500 1000 1750 4000
Max database size 500 GB 500 GB 500 GB 500 GB 1 TB 1 TB
Max in-memory OLTP storage 1 GB 2 GB 4 GB 8 GB 14 GB 32 GB
Max concurrent workers 200 400 800 1600 2400 6400
Max concurrent logins 200 400 800 1600 2400 6400
Max concurrent sessions 30000 30000 30000 30000 30000 30000

DTUs?

OK, so how many DTU’s do I need?  How is this measured?  Luckily Microsoft provides a DTU Calculator

This tool can help you analyze the workload of your Sql server over a 1 hour period to gather performance metrics.

You can feed this data into the DTU Calculator.  After clicking the calculate button, you’ll see several charts which provide an analysis of your database resource consumption. The charts depict the percentage of time (based on your measurements) that your database’s resource consumption fits within the limits of each Service Tier and Performance Level.  You can review CPU, Iops, and Log individually as well as collectively to better understand which metrics affect the performance of your database.

Azure also provides Sql Db Elastic pools.  SQL DB elastic pools provide a simple cost effective solution to manage the performance goals for multiple databases that have widely varying and unpredictable usage patterns.

https://docs.microsoft.com/en-us/azure/sql-database/sql-database-elastic-pool

In a nutsell, Azure SQL scalability levels are off the charts!  You can Scale SQL server from 1 small instance with 5 DTUs at $5 / month to P15 with 4000 DTUs at $16,000 / month.

Based on this customers usage patterns – 40-50 users and 100 more on the webapp.  This SQL server was way over scaled at P4!  But why was it running so poorly?

Luckily Azure SQL also provides some utilities to help look into your Azure Sql database performance

perfoptions

Selecting your Azure Sql database in the Azure Portal , find the Support & Troubleshooting section.  The performance overview and recommendations can help you.  In this customer’s case:

dbreccomend

The system was recommending I add indexes, I can even enable Automatic Tuning and have it create the indexes for me next time!

Indexes are critical to relational database server performance.  It wasn’t clear how the database got moved from on-premise last year to in Azure this year, but since they converted it to Sql Azure, they probably re-created the database schema and imported the data.  Sql Azure and Sql have different levels of flexibility. They must have forgot the indexes!

I recommended the customer apply the suggested indexes after hours to improve performance.  I also recommended he move back to an S2 or S3 instance size which should work fine for his workload once the database is tuned properly.

The next day the customer reported better performance.

Should you use Sql Azure or Sql Server?

When you create a database in Sql Azure, you have no control over database files and disk placement. The service imposes resource thresholds so that any bad behavior doesn’t upset the neighbors. With Azure SQL Database, you can move in quickly, but you can’t play music too loud or tear down any walls. If you need a low-maintenance environment with basic functionality, Azure SQL Database may be right for you.

SQL Server

SQL Server, on the other hand, is like owning your own home. It offers full functionality and the freedom to build your environment any way you like.  With that freedom comes responsibility, however. IT staff must administer all infrastructure, including the physical hardware, network, disk configuration, SQL Server configuration, backups, security and disaster recovery. If your organization requires a high degree of control and has the expertise to do it, traditional SQL Server may be your best choice.

SQL Server on Azure VM

Want to eliminate some of the hassle of upkeep and maintenance? SQL Server on an Azure VM offers a hybrid solution. The hardware and operating system provisioning and maintenance is done for you, but the SQL Server itself is fully under your control. Like owning a condo, you can paint the walls and renovate the kitchen, but never have to worry about mowing the lawn or fixing the roof. For those that want the best of both worlds, SQL Server on an Azure VM offers a viable solution.

The choice depends on what you need, when you need it, and how much you are willing to invest. Azure SQL Database, on-premise SQL Server, or SQL Server on Azure VM: one of them will work for you.

Why hosting your website on Azure is better than hosting it anywhere else!

The Microsoft Cloud offers huge advantages over other platforms to host your web based applications.  This article outlines several advantages to hosting your website or web application in Microsoft’s Cloud.

Multiple Deployment Slots

Built into Microsoft’s cloud is the ability to create “Deployment Slots” to stage your web content for testing. (Standard or Premium plan)

You can create up to 5 slots, (think Dev, Integration, QA, Staging, Production) environments that allow you to isolate and test new versions of your website before going live.  (up to 20 slots in Premium!)

Deploying a web app to a slot first and swapping it into production ensures that all instances of the slot are warmed up before being swapped into production. This eliminates downtime when you deploy your web app.

Each slot gives you a unique Url to test this specific version of your web application.

azuress1

This also lets you test new changes and updates without breaking your existing website.  You can simply swap slots with production to make your new version live!

Dynamic Scaling

How many servers do you have, how many do you need?  What if you want to do a big advertising campaign or social campaign, can your website handle the traffic?  Do you know it can?  Or are you guessing?

Azure lets you Scale Up (add CPU and Memory) or dynamically Scale Out ( add additional servers) automatically or on a schedule.

azuress2

This helps you make sure your website or application is highly available to handle inbound web traffic when needed.  Got an upcoming event?  It’s nice to know that your website can automatically scale to meet that demand and you won’t be wasting advertising dollars because your website is overloaded!

Traffic Manager

How are you treating your customers around the globe?  If you are selling a product or service online, you need to consider how well your website works in different regions around the world!

Now only can Azure help you test how your site is actually performing from various locations around the world, it can help you scale your site geographically as well.

azure_ss3

Azure CDN

Microsoft Azure data centers also have a Content Delivery Network (CDN) built-in that you can utilize for your applications.  A CDN puts your website content, (images, videos, scripts, etc)  closer to the user geographically.  This enabled your website to load much faster as the needed resources to display your website can be distributed in different data centers around the world.

azure_ss4

Proactive detection & Alerts

Do you wait for your customers to tell you your website is down or not working properly?  By that time you will have lost plenty of business and maybe even customers!

Azure has built in Proactive detection and alerting to notify you if there are problems with your website.  This helps you identify problem areas and key ways to make your website better!

azure_ss5

I don’t like Microsoft or Windows!

Fine, be that way..  Does Apple have a service like this?  Nope.. It’s ok to use your Mac, I understand.  You can still use Azure..

Azure supports .Net, Node.js, PHP, Python, and Java applications.  So you can host your stuff in Azure, but still use your Mac.  Happy?  It’s just a laptop, get over it already..

Why wait any longer?

The Microsoft Cloud continues to get better!  Microsoft has made huge investments in their cloud infrastructure and it’s really starting to show!

Move your website to the cloud today!  Don’t wait any longer!  You can’t afford to do business without the built-in tools and features of the Microsoft Cloud Platform.

Make the move, let Solid Cloud help!  We are Microsoft Azure Cloud Experts and would love to help you get the benefits the cloud can offer your business today.

http://SolidCloud.io

Gavin

Escaping Generics with T4 Templates

Originally posted on: http://geekswithblogs.net/gavin/archive/2010/03/13/138501.aspx

I’ve been doing some work with T4 templates lately and ran into an issue which I couldn’t find an answer to anywhere.  I finally figured it out, so I thought I’d share the solution.

I was trying to generate a code class with a T4 template which used generics

The end result a method like:

public IEnumerator GetEnumerator()
            {
                return new TableEnumerator<Table>(_page);
            }

the related section of the T4 template looks like this:

 public IEnumerator GetEnumerator()
            {
                return new TableEnumerator<#=renderClass.Name#>(_page);
            }

But this of course is missing the Generic Syntax for < > which T4 complains about because < > are reserved.

using syntax like <#<#><#=renderClass.Name#><#=<#> won’t work becasue the TextTransformation engine chokes on them.  resulting in : Error 2 The number of opening brackets (‘<#’) does not match the number of closing brackets (‘#>’) 

even trying to escape the characters won’t work: <#\<#><#=renderClass.Name#><#\<#> this results in:

Error 4 A Statement cannot appear after the first class feature in the template. Only boilerplate, expressions and other class features are allowed after the first class feature block. 

The final solution delcares a few strings to represent the literals like this:

<#+
   void RenderCollectionEnumerator(RenderCollection renderClass)
 {  
  string open = “<“;
  string close =”>”;
#>
   public partial class <#=renderClass.Name#> : IEnumerable
        {
            private readonly PageBase _page;
            public <#=renderClass.Name#>(PageBase page)
            {
                _page = page;
            }

            public IEnumerator GetEnumerator()
            {
                return new TableEnumerator<#=open#><#=renderClass.Name#><#=close#>(_page);
            }
        }
<#+
 } 
#>

This works, and everyone is happy, resulting in an automatically generated class enumerator, complete with generics!

Hopefully this will save someone some time 🙂

Custom XSLT for TRX Test Results

Originally posted on: http://geekswithblogs.net/gavin/archive/2009/08/25/134311.aspx

VS 2008 requires you have VS 2008 Test Edition to see the results of a Generic Test, this wasn’t sufficient with out current project as a lot of developers don’t use test edition.  I put together this custom xslt transform to convert the .trx test result file to an html report anyone can view, complete with collapsable sections…

Here is a link to the latest version of the XSLT:

http://yourcomputer.com/TRX2HTML.xslt

Here is the TrxConverter.cs file I use to Generate the html.

http://yourcomputer.com/TrxConverter.txt

Rename it to .cs

 

 

Time to Upgrade the certs..

Originally posted on: http://geekswithblogs.net/gavin/archive/2009/05/12/132066.aspx

Well, I was recently laid off from my Job of 5 years at Sage Software..  Sage has gone through 2 or 3 rounds of layoffs so far, the latest letting go of 500 employees in North America..

…”To help us better bring our costs in line with revenues, we are reducing staff by about 500 positions across the company, which includes employees as well as open positions that are being closed permanently. “

So, I’ve decided to take the opportunity to upgrade my Microsoft Certifications to the latest and greatest..  The last tests I took were in 2004, duting the .net 1.1 release..  Hard to believe it’s been so long..

Here is my current certs:

Microsoft Certification Status

  Credential Certification / Version   Date Achieved
 
  Microsoft Certified Application Developer   May 07, 2004
  For Microsoft .NET   May 07, 2004
  Microsoft Certified Solution Developer   Jun 11, 2001
  For Microsoft .NET   Sep 01, 2004
  Microsoft Visual Studio 6.0   Jun 11, 2001
  Microsoft Certified Professional   Apr 10, 2000

So, I’m going to take:

http://www.microsoft.com/learning/en/us/exams/70-553.mspx

http://www.microsoft.com/learning/en/us/exams/70-554.mspx

These 2 tests will allow me to upgrade my existing MCSD/MCAD to the new MCPD..  After taking these 2 tests I will have to take a few more to upgrade to .NET 3.0-3.5 certs, the MCTS..  I’m not sure right now if I’ll go that far, but maybe I should since I’m doing it.  I’ll have plenty of time if I’m unemployed..

These are all very difficult tests, I work fulltime as a contract developer and have for the last 15 years, but there are so many subjects you get tested on that you just don’t use everyday..  Hence, it will take alot of studying to get upto speed and feel like I can pass them.  Studying is hard, but you are forced to learn stuff that you should probbly know.  I’ve scheduled the above 2 tests for June 3rd, June 4th respectively.

I have yet to fail a Microsoft test, I guess I’ve studied hard enough in the past to make sure I can pass them.  We’ll see how it goes, I’m starting to study now, studying everyday during my lunch hour..

On a side note, If anyone knows of any contract positions available, please let me know.  I live in Phoenix, Arizona, so something local would be preferable, or something I can do remote word work also.  Thanks!

06/30/09 Update – Passed the 70-553, tough test…  Going to take the 70-554 next month..