Keep VS Code from Becoming an IDE (Ryan Palo) - Great finally! I super happy to see I'm not the only one doing that. Now what we need is a way to quickly change setups... Going from Markdown editor to Azure C# Function.
VS Code can do that?! (Burke Holland and Sarah Drasner) - Pretty cool little tips and tricks with vscode.
Authors Gary Keller, Jay Papasan That book was fantastic, and I really mean it. It helps on so many points! Professional, personal, social... It must be in your library. ISBN: 978-1885167774
I don't know for you, but I don't like losing time. This is why a few years ago I started using scripts to install all the software I need on my computer. Got a new laptop? N You just need to execute this script, go grab a coffee and when I'm back all my favorite (and required) softwares are all installed. On Linux, you could use apt-get, and on Windows, my current favorite is Chocolatey. Recently I needed to use more virtual machine (VM) in the cloud and I deceided that I should try using a Chocolatey script during the deployment. This way once the VM is created the softwares, I need is already installed! This post is all about my journey to get there, all scripts, issues and workarounds will be explained.
The Goal
Creating a new VM on premises applying the OS update and installing all the tools you need (like Visual Stutio IDE) will takes hours... This solution should be done under 10 minutes (~7min in my case).
Once the VM is available, it should have Visual Studio 2017 Enterprise, VSCode, Git and Node.Js installed. In fact, I would like to use the same Chocolatey script I use regularly.
In this post I will use Azure CLI, because it will works on any environment. However, PowerShell can also be use only a few command will be different. The VM will be deploy with an Azure resource Manager (ARM) template. To create and edit the ARM template I like to use VSCode, you don't need it but it's so much easier with it! I use two extension.
The first one Azure Resource Manager Snippets will help by generating the schema for our needs. In a JSON file you just need to type arm en voila! You ahave a long list of ARM template!
The second is Azure Resource Manager Tools. This extension provides language support for ARM and some validate. Very useful...
Creating the ARM Template
To Get started create a new JSon file. Then type arm and select the first option; to get an empty skeleton. Then add an extra line in resources and type again arm. This time scroll until you see arm-vm-windows.
A multi-cursor will allow you to edit the name of your VM everywhere in the file in one shot. Hit Tab to navigate automatically to the userName, and Tab again to go to the password.
Now we have a functional ARM template that we could deploy. However, let's add a few things first.
Searching the Image SKUs by Code
One of my favorite VM images for a DevBox is the one that includes Visual Studio pre-installed. One thing to know is those images are only deployable in an MSDN subscription. To specify wich image you want to use you need to pass a publisher, offer, and sku.
Here how to do it with Azure CLI commands
# List all the Publishers that contain VisualStudio (It's case sensitive)
az vm image list-publishers --location eastus --output table --query "[?contains(name,'VisualStudio')]"
# List all offers for the Publisher MicrosoftVisualStudio
az vm image list-offers --location eastus --publisher MicrosoftVisualStudio --output table
# List all availables SKUs for the Publisher MicrosoftVisualStudio with the Offer VisualStudio
az vm image list-skus --location eastus --publisher MicrosoftVisualStudio --offer VisualStudio --output table
Now that all the information is found, search in the ARM template and replace the current values by the one found. In my case, here are the new values.
Great now we have a VM with Visual Studio but our applications are still not installed. That will be done by adding the Custom Script Extension for Windows to our template. documentation page, a sample schema is there ready to be use.
The last node of your template is currently another extension. For the purpose of this blog post let's remove it. You should have something like this.
We will copy/ paste the snippet from the documentation page a change a few little things. Change the type (thank to our VSCode Extension for that catch). Update the dependencies to reflet our demo.
To use the extension your script needs to be available online. It could be in a blob storage (with some security) or just publicly available. In this case, the script is publicly available from my gist.github page. I created a variable in the variables section that contains the RAW URL of my script, and a reference to that varaibale is used in the fileUris.
The extension will download the script and then execute a function locally. Change the commandToExecute to call our script with unrestricted execution policy.
You have a timed window of ~30 minutes to execute your script. If it takes longer then that, your deployment will fail.
# First, we need a Resource Group
az group create --name frankDemo --location eastus
# ALWAYS, always validate first... you will save a lot of time
az group deployment validate --resource-group frankDemo --template-file /home/frank/Dev/DevBox/FrankDevBox.json
#Finally deploy. This script should take between 5 to 10 minutes
az group deployment create --name FrankDevBoxDemo --resource-group frankDemo --template-file /home/frank/Dev/DevBox/FrankDevBox.json --verbose
What's Next?!
We created one template; you could make it better.
Deploy from anywhere
By moving the computerName, adminUsername, adminPassword, and the script url in the parameters section, you could then put the template in a public place like GitHub. Then with use the one click deploy!
Directly from the Github page or from anywhere you just need to build a URL from those two parts: https://portal.azure.com/#create/Microsoft.Template/uri/ and the HTML Encoded URL to your template.
If my template is available at https://raw.githubusercontent.com/FBoucher/SimpleDevBox/master/azure-deploy.json then the full url become:
It's very easy to forget to turn off those VM. And whatever you are paying for them or your using the limited MSDN credit it's a really good practice to turn them down. Why not do that automatically!
That can be very simply done by adding a new resource in the template.
Do you have to know English to be a Programmer? (Scott Hanselman) - Interesting post... At the end, English may not be a blocker...but you need some base. Otherwise, how could you even read this post!
Copy, Download or Upload from-to any combination of Windows, Linux, OS X, or the cloud
Data is and will always be our primary concern. Whether shaped as text files, images, VM VHDs or any other ways, at some point in time, our data will need to be moved. I already wrote about it previously, and the content of this post is still valuable today, but I wanted to share new options and convert all ground (meaning Linux, Windows and OS X).
Scenarios
Here few scenarios why you would want to move data.
Your Microsoft Azure trial is ending, and you wish to keep all the data.
You are creating a new web application, and all those images need to be moved to the Azure subscription.
You have a Virtual Machine that you would like to move to the cloud or to a different subscription.
...
AZCopy
AzCopy is a fantastic command-line tool for copying data to and from Microsoft Azure Blob, File, and Table storage. At the moment, to write this post AzCopy is only available for Windows users. Another solution will be introduced later in this post for Mac and Linux users. Before AzCopy was only available on Windows. However, recently a second version built with .NET Core Framework is available. The commands are very similar but not exactly the same.
AzCopy on Windows
In his simplest expression, an AzCopy command looks like this:
If you earlier have installed an Azure SDK on your machine, you already have it. By default, AzCopy is installed to %ProgramFiles(x86)%\Microsoft SDKs\Azure\AzCopy (64-bit Windows) or %ProgramFiles%\Microsoft SDKs\Azure\AzCopy (32-bit Windows).
If you need only AzCopy for a server, you can download the latest version of AzCopy.
Let's see some frequent usage. First let's say you need do move all those images from your server to an Azure blob storage.
These examples were simple, but AzCopy is a very powerful tool. I invite you to type one of the following commands to discover more about using AzCopy:
For detailed command-line help for AzCopy: AzCopy /?
For command-line examples: AzCopy /?:Samples
AzCopy on Linux
Before you could install AzCopy you will need to install .Net Core. This is done very simply with few commands.
It is very similar to the original version, but parameters are using -- and - instead of the / and where a : was required, it's now a simple space.
Uploading to Azure
Here an example, to copy a single file GlobalDevopsBootcamp.jpg to an Azure Blob Storage. We pass the full local path to the file into --source, the destination is the full URI, and finally the destination blob storage key. Of course, you could also use SAS token if you prefer.
To copy the image to a second Azure subscription, we use the command the source is now an Azure Storage URI, and we pass the source and the destination keys:
Azure CLI is a set of cross-platform commands for the Azure Platform. It gives tools to manipulate all Azure components, but this post will focus on azure storage features.
There are two versions of the Azure Command-Line Interface (CLI) currently available:
Azure CLI 2.0: written in Python, conpatible only with the Resource Manager deployment model.
Azure CLI 1.0: written in Node.js, compatible with both the classic and Resource Manager deployment models.
Azure CLI 1.0 is deprecated and should only be used for support with the Azure Service Management (ASM) model with "classic" resources.
Installing Azure CLI
Let's start by installing Azure CLI. Of course, you can download an installer but since everything is evolving very fast with not getting it from Node Package Manager (npm). The install will be the same, you just need to specify the version if you absolutely need Azure CLI 1.0.
sudo npm install azure-cli -g
To keep the previous scenario, let's try to copy all images to a blob storage. Unfortunately, Azure CLI doesn't offer the same flexibility as AzCopy,and you must upload the file one by one. However, to upload all images from a folder, we can easily put the command in a loop.
for f in Documents/images/*.jpg
do
azure storage blob upload -a frankysnotes -k YoMjXMDe+694FGgOaN0oaRdOF6s1ktMgkB6pBx2vnAr8AOXm3HTF7tT0NQWvGrWnWj5m4X1U0HIPUIAA== $f blogimages
done
In the previous command -a was the account name, and -k was the Access key. This two information can easily be found in the Azure portal. From the portal (https://portal.azure.com), select the storage account. In the right band click-on Access keys.
To copy a file (ex: a VM disk aka VHD) from one storage to another one in a different subscription or region, it's really easy. This time we will use the command azure storage blob copy start and the -a and -k are related to our destination.
The nice thing about this command is that it's asynchronous. To see the status of your copy just execute the command azure storage blob copy show
azure storage blob copy show -a frankshare -k YoMjXMDe+694FGgOaN0oPaRdOF6s1ktMgkB6pBx2vnAr8AOXm3HTF7tT0NQVxsqhWvGrWnWj5m4X1U0HIPUIAA== imagesbackup 20151011_151451.MOV
Azure CLI 2.0 (Windows, Linux, OS X, Docker, Cloud Shell)
The Azure CLI 2.0 is Azure's new command-line optimized for managing and administering Azure resources that work against the Azure Resource Manager. Like the previous version, it will work perfectly on Windows, Linux, OS X, Docker but also from the Cloud Shell!
Cloud Shell is available right from the Azure Portal, without any plugging.
Uploading to Azure
The command if the same as the previous version except that now the command is named az. Here an example to upload a single file into an Azure Blob Storage.
Let's now copy the file to another Azure subscription. A think to be aware is that --account-name and --account-key are for the destination, even if it's not specified.
If you prefer, I also have a video version of that post.
One More Thing
Sometimes, we don't need to script things, and a graphic interface is much better. For this kind of situation, the must is the Azure Storage Explorer. It does a lot! Upload, download, and manage blobs, files, queues, tables, and Cosmos DB entities. And it works on Windows, macOS, and Linux!
It's just the beginning
This post was just an introduction to two very powerful tools. I strongly suggest to go read in the official documentation to learn more. Use the comment to share all your questions and suggestion.
A flexible new way to purchase Azure SQL Database (Alexander (Sasha) Nosov) - A new kind of hybrid way to get your databases in Azure. It's not a full service, neither full pure VM... It definitely looks like less trouble for better performance.
A really amazing book packed of very interesting advice. Things that you kind of already knew, or at least had a feeling you maybe knew are clearly explained to you.
After reading (or listening) this book, you will know why, and you can decide to fight it or change the when... improve your performance and use your time and energy on something else.
Know your Azure Subscription Quota and Usage (Wriju Ghosh) - Because waiting until it breaks is probably not the option you are looking for... It's a good idea to know your quotas first.
MVC vs Razor Pages - A quick comparison (Jon Hilton) - Interesting post that compares two architecture. However, all the unit-test and mocking/ dependency injection were not included...Nevertheless it worth reading f you hare new in .Net Core development.
Making an Azure static website EVEN MORE secure (Julian M Bucknall) - This post is like a pleasant journey in the security word. You will probably learn a lot, just like the author did (and myself obviously)
Data
Azure Cosmos DB training webinars - Cosmo DB is gaining in popularity. It's time to boost your skill check this webinar/ on-demand training.
Capturing Power BI queries using DAX Studio (Marco Russo) - Great post that gets us started on ways to find optimization for our Power Bi. Not enough people know about DaxStudio, have a look it's free!
Making Time(Bob Clagett) -I really enjoyed reading that book. I've been watching Bob's YouTube Channel for a while. ANd was happy to ear about his new book. In Making Time, a little bit like in his videos, Bob explains how he build stuff... but this time instead of a furniture or a room, it's a new career/ business. A short book (88 pages) but a lot of fun.
Last week, it was the 25 edition of the MVP Summit. An event, where Microsoft invites all his MVP to get to Seattle and spend some time with the products teams and learn on the latest news and best practices.
This year was particularly inspiriting by the Microsoft roadmap, of course, but even more by all the amazing people a got the chance to meet and discuss with. I'm all pump-up, and I have tons of ideas and projects… more to come.
I already miss you…
Cloud
Deploy Docker containers fast to Microsoft Azure (Michelangelo van Dam) - This is an excellent tutorial to get started with Docker and also to see what's possible with Azure Container Instance service (ACI).
The Modern Dev Team (Rob Conery) - What a great post. Maybe it's only me getting old ;) but I think we all have these thoughts one day or the other.
Cloud
A great developer experience for Ansible (Corey Sanders) - This post announces the integration of Austin in the cloud shell and visual studio. It somewhere we can learn more about it. I didn't know about it, but I really want t use in my next DevOps tasks.
Azure Functions Proxies (Eric Williams) - Azure Functions are a very useful thing to have in your toolbox. With the addition of Proxies, it becomes a must read a few ways to use them in this post.
Jenkins on Azure: from zero to hero (Pui Chee Chan) - Jenkins is an extremely popular build server. This post list all the features pre-package for you when you deploy it in Azure in a few click.Pretty awesome.
My Favorite SQL Prompt Features (MarlonRibunal) - If you never try SqlPrompt and you write SQL in your day to day, stop read this, and go downloading it, or at least read this post that gives you a glimpse of it's feature.
Virtual machines (VM) are used in most solutions nowadays as a [ProcessName] server, temporary machine to run tests or make demos, and sometimes even as a development machine. One of the great benefits of the cloud is that you only pay for what you use. So unlike the old server, that you keep paying for, you won pay virtual machine's CPU for when you turned off! In this post, I explain how to do it with your existing machines and also what to do with all the future one that you will be creating.
From the Azure portal (portal.azure.com), select the Virtual Machine (VM) that you which to edit. Then look at the option panel, on the left, for Auto-Shutdown in the Operations section. You should have something that looks like this:
At any time you can enable and disable that functionality, it won’t affect the running VM.
Now, to activate it click on the Enabled. Then Select the time you would like to see the VM shutdown. Be sure to select the good time zone, by default it’s UTC. You can adjust the at for UTC of change the time zone, both options are valid.
Now you could decide to enable the notification. That could be useful if you may want to postpone the shutdown for one or two hours, or integrate the shutdown to another process like backup, cleaning…
To activate the notification option just click on the enabled, and enter the email address. If you want to attach the shutdown to a Logic App or an Azure Functions use the webhook. Here an example of notification email, see the Postpone options link.
What if you have many VMs running
Let's say you have already twenty (or more) VMs running, you could have executed a PowerShell script like:
Update - 2018-03-14 Well, today this is only possible for VM part of a DevTest Labs. Not for "regular" VM. However, I'm sure that day will come pretty quick.Does that mean that you need to go in all your VMs and set it manually? No. You can use an Azure Automation that will stop a list of VM on a regular schedule. A big advantage of this solution is that you can be more creative since it offers a lot more flexibility. You could identify the VM to shutdown base on some TAGS, you could have a different schedule base on the week vs weekend. You could even have a task to start VMs in the morning... More to come on that topic in a future post... If you want to read about how to get started to Azure Automation click here.
Multiple VMs that already exist, no problem
Obviously, if you have multiple virtual machines that already exist it is not very efficient to change their configuration one by one via the portal. Here is a small script to change the configuration of a large amount of VM in one shot.
The variable $selectedVMs contains all the VMS that we wish to edit. In this sample, I only get VMs contained in the RessourceGroup cloud5mins, but there are no limits to what you can do. You could select all VMs with a specific OS, tags, location, name, etc.
The variable $ScheduledShutdownResourceId will be the identity for the configuration for the auto-shutdown we wish to inject. Note that the provider is microsoft.devtestlab.
Next, we create a collection of properties in $Properties. status the one that active or deactivate the auto-shutdonw. targetResourceId is the resourceID of the VM we target.
The only things left is to specify the time and timezone.
If you prefer, I also have a video version that explains all the steps.
How to shutdown automatically all your existing VMs
End Update
Let's create a VM with the auto-shutdown pre-configured with ARM
Of course, a much more efficient way to set the auto-shutdown is at the creation time by adding a new resource of type Microsoft.DevTestLab/schedules to your template. This option was previously only accessible for DevTestLab, but recently was made available to any VMs.
Here an example of the variables that could be added to your template.
And here an example of Microsoft.DevTestLab/schedules resource. One of these should be added for every VM you wish to auto-shutdown. Because your script is for one server, however, only one instance is required.
Exploring the Azure IoT Arduino Cloud DevKit (Scott Hanselman) - This is an excellent post to know where to star with arduino and make your mind of what to expect in terms of effort vs result.
How to Scale Your API Design Process with OpenAPI (Ryan Pinkham) - This post introduces SwaggerHubs. I didn't know about this tool, it looks really good. As a heavy Azure user cannot miss some similitude with Api Managment. I will definitely give it a try.
Styling Social Media Icon Lists in CSS (Mark Heath) - Yeah right, we can read CSS and probably hack some stuff... But it's excellent to learn how to do simple things the good way. And this post shows exactly that.
Power BI Desktop January Feature Summary (Amanda Cofsky) - It looks like some team did not take a lot of time-off during the Holidays... So many great new functionalities; it's a fantastic way to start the year.