Azure, PowerShell, Technical

New Service Fabric PowerShell Cmdlets

If you prefer to use PowerShell to interact with Azure and you are working with Service Fabric, today is your lucky day! Technically, //Build held a couple weeks ago was your lucky day since that’s when these were released but today is when I’m getting around to writing this post.

Announced a couple weeks ago, there are some new cmdlets that allow you to do cluster management. Tasks such as creating a cluster, adding/removing a node, adding/removing a node type, changing reliability or durability, things like that, are now possible using PowerShell. As of today, here are the new commands, currently at v 0.1.1:

Add-AzureRmServiceFabricApplicationCertificate
Add-AzureRmServiceFabricClientCertificate
Add-AzureRmServiceFabricClusterCertificate
Add-AzureRmServiceFabricNode
Add-AzureRmServiceFabricNodeType
Get-AzureRmServiceFabricCluster
New-AzureRmServiceFabricCluster
Remove-AzureRmServiceFabricClientCertificate
Remove-AzureRmServiceFabricClusterCertificate
Remove-AzureRmServiceFabricNode
Remove-AzureRmServiceFabricNodeType
Remove-AzureRmServiceFabricSetting
Set-AzureRmServiceFabricSetting
Set-AzureRmServiceFabricUpgradeType
Update-AzureRmServiceFabricDurability
Update-AzureRmServiceFabricReliability

For the latest documentation, check out the docs.

Installation

Admittedly, I’m not a huge PowerShell user. But, I wanted to at least give these a quick test run. Especially focusing on the New-AzureRmServiceFabricCluster command as that lets us now create a new cluster without writing an ARM template! Pretty cool…for the scenarios where it supports the customizations we need. More on that later. I mentioned I wasn’t a huge PowerShell users, and by that I mean to say I didn’t even have the Azure PowerShell SDK installed on my main machine. So I went off to install it. Just my luck, the first install didn’t go so well as when I tried running some of these new commands I got an error saying I needed to run Import-Module on AzureRM.ServiceFabric. Well, when I did that I got this error:

Import-Module : The module to process ‘.\Microsoft.Azure.Commands.ServiceFabric.dll’, listed in field ‘NestedModules’ of module manifest ‘C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.ServiceFabric\AzureRM.ServiceFabric.psd1′ was not processed because no valid module was found in any module directory.

Indeed, the dll it was looking for didn’t exist. After some unsuccessful troubleshooting I gave up and removed the SDK and reinstalled. That time it worked.

Create a New Cluster

Starting with Hello World, I wanted to create a new cluster. Nothing fancy, just following one of the examples given in the help documentation. Updating my script, I ended up with this (watch for wrapping if you copy/paste):

$pwd=“OneSuperSecret@99” | ConvertTo-SecureString -AsPlainText -Force
$RGname=“testposhasf”
$clusterloc=“SouthCentralUS”
$subname=$RGname.$clusterloc.cloudapp.azure.com”
$pfxfolder=“c:\MyCertificates\”

Write-Output “create cluster in ” $clusterloc “subject name for cert ” $subname “and output the cert into ” $pfxfolder

New-AzureRmServiceFabricCluster -ResourceGroupName $RGname -Location $clusterloc -ClusterSize 3 -VmPassword $pwd -CertificateSubjectName $subname -CertificateOutputFolder $pfxfolder -CertificatePassword $pwd -OS WindowsServer2016DatacenterwithContainers

That creates a 3 node cluster using the Server 2016 w/Containers OS and secures it by creating a new cert and storing it in Key Vault along with downloading it locally so I can use it. (Install it locally before trying to access Service Fabric Explorer.) It took around 10ish minutes and resulted in a usable cluster, all without writing a single line of JSON!

And here’s the Resource Group view, showing all of the artifacts it created for me:

A few things to point out:

  1. While this command does create a secure cluster, notice it created the Key Vault in the same Resource Group. Not really the best deployment scenario, but it gets the job done. If you’d prefer to use an existing Key Vault, use one of the other options of the same command to create a new Key Vault Resource Group. Examples are shown in the help.
  2. For some reason, it created the cluster with version 5.5.216 of the Service Fabric runtime, whereas the latest version is 5.6.210 (and preferred when using Windows containers). Hopefully this will get fixed soon.
  3. If you don’t like the naming scheme (does “l5nbd6qsesaeu100” mean anything to you?), you’ll need to create a JSON template.
  4. For control over many other options (such as deploying into an existing VNET), you’ll be back in JSON.
  5. Just because you’re back in JSON, you can still leverage this command by passing in your template file (see the other examples).

All-in-all, I think this is a great start and I like where the tooling is going. I can’t wait to see these capabilities grow and, hopefully, be adopted over in the CLI world.

Docker, Linux, Technical

Oracle Database on Docker for Windows

Coming out of DockerCon this year one of the announcements I was most excited about was from Oracle with their Docker support. I don’t know why I was excited about it as I haven’t used Oracle for a project in over 12 years, but odd things excite me. Since I have Docker for Windows running on my Windows 10 laptop, I decided I would use that to create an image of Oracle Database 11.2.0.2 Express Edition. I won’t rehash the steps here as the good folks at Oracle have done a decent job of this already, but I will call out a few things I noticed:

  • Don’t un-compress the installation binaries after downloading. Yeah, I know they call that out in the docs, but I missed it initially.
  • Be patient. Or multi-task.
    snip_20170522172249
  • And most importantly, Express expects at least 2048MB swap space. The MobyLinuxVM used by Docker for Windows only has 1024MB. So you will get an error stating:
    ”This system does not meet the minimum requirements for swap space. Based on the amount of physical memory available on the system, Oracle Database 11g Express Edition requires 2048 MB of swap space. This system has 1023 MB of swap space. Configure more swap space on the system and retry the installation. “

So unless someone out there can tell me how to set up a larger swap space in that VM, we are stuck and can’t use Docker for Windows. Dammit. I did tag on to an existing Docker forum post, so we’ll see if that bears any fruit.

In the meantime, I fired up an Ubuntu image in Azure and installed Docker and used that to create the container. I didn’t create it with swap space so I did have to go in and add that (I used this method), but once that was setup the image was created just fine. Previous note applies regarding patience and/or multi-tasking.

snip_20170522173310

Not the smallest of images, but there you have it. Now I can fire up an Express Database running in Docker by running:

docker run –name oracleexpress –shm-size=1g -p 1521:1521 -p 8080:8080 -e ORACLE_PWD=tmppassword oracle/database:11.2.0.2-xe

After about 5 minutes, you’ll have a running container! To test the connection and make sure it was running, I logged in using sqlplus from the container:

docker exec -ti oracleexpress sqlplus system/tmppassword@//localhost:1521/XE

Connection successful, and I was able to query the database!

snip_20170522212954

Here’s the image up on Docker Hub if you just want to pull it and start playing.

Now to figure out that MobyLinuxVM swap space…

P.S. If there was any doubt it would run on Windows 10, here it is running on my Windows machine after pulling the image down from Docker Hub (click the image for full screen):

Linux, Technical

Launch Visual Studio from Bash on Windows

Since I’m starting to use Bash on Windows (WSL) more regularly, I added a quick way to launch Visual Studio 2017.

  1. Edit .bashrc and add the VS path (I’m obviously using Enterprise so your path may be different):  export PATH=$PATH:”/mnt/c/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE”
  2. I chose to add an alias, so I also added this to my .bashrc:  alias vs2017=devenv.exe
  3. Reload your shell:  . /.bashrc

Now I can quickly pop open Visual Studio by using “vs2017”. For example, to open an existing solution I can navigate to the folder containing the .sln and simply type “vs2017 mysolutionfile.sln” at my bash prompt and VS2017 will fire up with that project loaded.

Here’s my .bashrc if you want to see the full file.