Posts

Integration test experiments - running IdentityServer and ASP.NET Core WebApi inside a Process

Hello.  I'll get to the main topic of this post shortly (and a link to my github repository with the sample code at the end) but just wanted to give you a bit of background first.  Recently I've been studying security engineering with a view toward strengthening my skills in that area.  - I attended a two-day workshop on Identity and Access Control by Dominic Baier (one of the creators of IdentityServer4 ) at NDC London.  This was a real eye-opener, and in turn led me to a few other avenues of research.  It turns out this extra time I've got in lockdown can be put to use... - I'm reading a book he recommended to me which is considered a seminal work in the field, "Security Engineering" by Ross Anderson.  It's a massive tome so I'm working my way through it slowly but it's clearly essential reading. - I'm reading up on OAuth 2.0 and Open ID Connect  with a view toward eventually being thoroughly conversant with all the concepts,

Azure ServiceBus PeekBatch or ReceiveBatch don't reliably get all messages

I had a requirement with respect to Microsoft's Azure ServiceBus to "resubmit all the messages in the Dead Letter Queue back to the original topic."  Say the messages were dead lettered because of some transient failure and you just want to resubmit them.  So you would think you could just get a reference to the dead letter queue, loop through all the messages (or grab them asynchronously in a batch) and easily process them all. Turns out it's not so simple if your subscription is a partitioned queue.  You might have an impulse to use the "PeekBatch" or "ReceiveBatch" commands to say, grab all the messages, then process them, as in this stack overflow post  which describes how it does not reliably grab all the messages.  This is because (in our case) we were using a partitioned queue.  So the message might be in a different partition, which is why you're not getting all of them.  See the "Browse/Peek messages" section of this MS po

The database platform service with type Microsoft.Data.Tools.Schema.Sql.SqlAzureV12DatabaseSchemaProvider is not valid

I got this error while trying to import a BACPAC from SQL Azure, into a local SQL server (LocalDb) instance.  This was using the DacServices.ImportBacpac method.  I had previously received BACPAC files from my esteemed DevOps colleagues which did not generate this error, but this particular set of BACPACs did. If you google this error, mostly what you find is people who are getting the same error while trying to import the bacpac manually in SSMS.  But in my case I was trying to do it programmatically.  Anyway those posts mostly suggest upgrading SSMS to the latest service pack etc, which I tried, to no avail.  I also thought maybe if I changed the parameters it might help, but in fact there weren't many parameters to change. So I went back to the old school method (using SqlPackage.exe from the command line).  But then I got a different error : you must have a user with the same password in master. Eventually I hit upon a method that worked, which was to use the connec

Why make things consistent?

Things should be consistent.  When we're talking about I.T. artefacts (how we build databases, how we structure database tables, how we write code, etc etc) we should build them consistently. This ought to be obvious.  But wherever I go, I see quite the opposite.  Many software applications, or I.T. departments, or enterprises, are basically a collection of various artefacts, all of which have been built INCONSISTENTLY.  And then people wonder why it's so hard to manage all this. The reasons things become inconsistent are many.  Here are a few examples: - Many different developers looking at the same application over time, but not paying any attention to existing patterns.  In other words, for whatever reason (maybe they haven't been trained to see in this way), they don't actually SEE the pre-existing patterns. - Developers think they have a better way of doing something so they just start doing things their way, without any regard for pre-existing patterns.  

npm outdated + npm update is your friend

In the last year or two I've been getting my head around the whole world of front-end web development with AngularJS and its associated infrastructure ( nodejs , npm , bower , gulp , etc).  A lot of that has to do with the fact that with my current client, I've been working on projects that use all that technology (where they have Microsoft's  ASP.NET WebApi on the back-end, and all this other stuff on the front-end). It seems to me a lot of .Net developers shy away from really learning all that stuff, or they just learn what they need to know to get the job done, but I think all this stuff is pretty cool and I've been trying to learn it all on a slightly deeper level. So when you get into the whole  npm  thing you quickly learn that development tools, libraries, packages, plug-ins etc. that are required by your project are stored in a file called package.json .  And that the versions of those packages are managed with symbols using a syntax called semver . So,

Recover Azure VM password (Reset Azure VM password)

If you find you've changed your password on your Azure Virtual Machine, but then subsequently forgotten it (and I swear I was entering the correct password, but apparently not), then you google phrases like "recover azure vm password" etc, you may run across blog posts from Microsoft like the one found here . There are two things to note which are not entirely obvious from the steps listed there.  One is, if you don't use PowerShell every day you may launch the PowerShell command prompt and not the ISE as they suggest.  You do in fact want the ISE, not the command prompt.  For example on a Windows 2008 server machine the ISE is under Accessories... Windows PowerShell... Windows PowerShell ISE. The other thing is, if you're trying to reset the password of your VM, the VM actually has to be powered up.  (Duh!)  In retrospect this is obvious; how can you reset the password of your VM if the VM is not actually powered up?  You can't. But if it is powered up

Elmah + ASP.NET WebAPI tip...

I had one of those situations today where you're looking at various blog posts and stack overflow posts and everybody's essentially saying, "it's easy, you just add the NuGet package, issue a couple lines of configuration code, and it works."  But I was scratching my head for awhile until I connected the dots.  So I thought I'd post a small tip here in hopes of saving somebody a minute or two. So, if you want to add ELMAH to your ASP.NET WebAPI project to log unhandled exceptions, a bit of googling will quickly lead you to the elmah-contrib-webapi project, and helpful posts such as this one and this one , as well as various stack overflow posts .  I tried the stuff recommended there but for some reason couldn't get it working.  Having used ELMAH previously on an MVC project, I knew that the basic steps are: Install a NuGet package Tweak your web.config Point to where you want to log to (on my previous project it was logging to SQL Server, but