Showing posts with label json. Show all posts
Showing posts with label json. Show all posts

Reading Notes #582

It is time to share new reading notes. It is a habit I started a long time ago where I share a list of all the articles, blog posts, and books that catch my interest during the week. 

 If you think you may have interesting content, share it!
Fridge with wings, realistic rendering 


 

Cloud

Data


Programming


~Frank

Reading Notes #546


Cloud

Programming

Podcasts

Books


  • Learning Blazor
    (David Pine) - This book is just perfect! It explains a bit of everything. It is packed with real examples and code variation (because there are so many ways to write something). There was even a full chapter un test with playwright, I didn't expect that and it was great!

Reading Notes #544


It is time to share new reading notes. It is a habit I started a long time ago where I share a list of all the articles, blog posts, podcast episodes, and books that catch my interest during the week.

If you think you may have interesting content, share it!

Programming

Podcasts

~Frank


How to edit a JSON object inside an Azure Logic App

I use Azure Logic Apps in many of my solutions, I find them so conviennant to integrate different systemes. Recently one of them was failling and by lookink at the error message: The property value exceeds the maximum allowed size, I knew what was wrong. I was tying to save a JSON object into a Storage table but one property was too long. For this particular case I didn't need the value contain in the property so the plan was to delete it. At first, I thought it wasn't possible to edit a variable of type object in a Logic Apps, but it is!

In this post I will show how to use Compose action and setProperty to perform data operations in Azure Logic Apps.

The Context

First think to know is that the Compose action does not update the the current object but creates a new one. In this demo the JSON object use is quite short to simplyfy the demo.

{
	"firstname":"Frank",
	"lastname":"Boucher",
	"alias":"fboucheros",
	"bio":"With many years of experience in the IT industry, François (Frank) Boucher is a trusted Microsoft Azure professional whose expertise and bilingual service are relied upon in large Canadian markets (Ottawa and Montreal) as well as internationally. Among his many accolades, Francois has been awarded four times Microsoft Azure MVP status, named a Microsoft Azure Advisor, and Microsoft Azure P-Seller. Frank created the “Cloud 5 minutes” show. Where every second week, a new episode that answers a different technical question, is published both in French and English (cloud5mins.com). "
}

The Details

The Logic App recieve a JSON object from the request body. This is transfom as an Person object. To empty the bio property the action Compose will be used.

Inside the Compose action, use the context menu to find setProperty in the Expression section. The expression setProperty takes three parameters: the object, the property name, and the edited value. In this demo the goal was to empty the property therefore and empty string will be assign like this:

  setProperty(variables('Person'),'bio','').

The edited object is accessible from the output of the Compose action and this what will be return in the Response action.

The Result

By adding a single action it's possible to edit JSON object in a Logic App without requiring to use inline code or external tools. A demo wouldn't be complite without a end-to-end run so here the result of a HTTP POST to the Logic App passing the Person JSON and the returned result.

Video version

If you prefer, I also have a video version of this post.

Useful links


~ Frank



Reading Notes #504


Good Monday, Already time to share new reading notes. Here is a list of all the articles, blog posts, and podcast episodes that catch my interest during the week. 

If you think you may have interesting content, share it!

Cloud

Programming

Miscellaneous

~Frank

Reading Notes #488


Good Monday, time to share my reading notes. Those are a curated list of all the articles, blog posts, podcast episodes, and books that catch my interest during the week and that I found interesting. It's a mix of the actuality and what I consumed.

You think you may have interesting content, share it!

Programming

Books

Effortless: Make It Easier to Do What Matters Most 
(Greg McKeown) 

- Nice continuity of his first book Essentialism. I appreciated this reading. Many simple and easy ideas that we can start to apply. If interested in this topic Greg also has a podcast: What's Essential.






~Frank

Reading Notes #486


It's Monday (the cyber one), time to share my reading notes. Those are a curated list of all the articles, blog posts, podcast episodes, and books that catch my interest during the week and that I found interesting. It's a mix of the actuality and what I consumed. 

You think you may have interesting content, share it!

 

Cloud

Programming

~Frank

Reading Notes #369

Cloud


Programming


Miscellaneous


~

Reading Notes #339

IMG_20180725_154113

Cloud



Programming



Data



Miscellaneous



~Enjoy!


Reading Notes #246

IMG_20160826_115405Cloud


Programming


Databases


Miscellaneous


Reading Notes #235

ImaginationSuggestion of the week


Cloud


Azure Resource Manager (ARM) for beginners

(Ce billet en aussi disponible en français: Azure Resource Manager (ARM) pour débutants)

You know that image where you see people pulling a cart with square wheels, a man on the side wants to show them a circle wheel but the group reply they are too busy to care... Well, that was me with Azure Resource Manager (ARM). I knew it was good, but it looks too complicated, so I was waiting. Last weekend, I decided it was enough I needed to learn it! Right after few minutes, you cannot imagine my disappointment! It's so simple, so powerful and also so fast. This post explains how to deploy an ARM template, and how it works.

squarewheels

5 easy steps to deploy our first ARM template


To get started the easiest way possible I decided to use Visual Studio. For this sample let's create simple Windows Virtual Machine (VM). Only five steps are required to do it:

Step #1 - Create an Azure Resource Project

From Visual Studio create a new project of type Azure Resource Group. Be sure to have already installed on your machine the latest version of Azure SDK and Visual Studio updates.

step-1-Create_arm_project.1

Step #2 - Select the Arm template

This is where we select what we want in our template. Many options are available in VisualStudio and a lot more can be found on Github at: Azure Arm Git Template. In our case, let's select the sample Windows Virtual Machine, and click the Ok button.

step-2-Select_Tempplate

Step #3 - Deploy the new template

Visual Studio will now generate multiple files, we will come back to it later, right now we will only deploy our solution. Right-click on the project et select Deploy.

step-3-Start_deploy

Step #4 - Configure the deployment

Our first deployment is mostly ready, we just need to specify few details like the subscription and the resource group. Once you click Deploy, one last thing will be asked: the adminPassword.

step-4-Config_deploy

Step #5 (the easiest one) - Enjoy

Voila! After few minutes, the virtual machine will be created, and we should be able to connect remotely to it.

Let's explain the magic


When the project was created, three folders were populated: Script, Template, and Tools. The last one is a bit obvious, it contains AzCopy, a tool to copy files. If you don't know AzCopy, you can learn more in a post I wrote recently.

Open the Deploy-AzureResourceGroup.ps1 contained in the Scripts folder. It's this script that will do all the hard lifting to deploy our rescourceGroup. If we look a bit closer, you will notice some parameters are declared, at the beginning of the file. Two of then should catch our attention.
    [string] $TemplateFile = '..\Templates\WindowsVirtualMachine.json',
    [string] $TemplateParametersFile = '..\Templates\WindowsVirtualMachine.parameters.json',

TemplateFile is the path of our template (the one we selected previously), and the second TemplateParametersFile will contained all the parameters values to fill the blank of our template. This will be especially useful to deploy the same template in a different environment. In fact, this is a really big advantage. You can deploy the exact same schema to your development and production environment just by having two parameters.json file.

Let's have a peek at the template, in this case WindowsVirtualMachine.json. It's a 'json' file, so it's human-friendly, but it can be a bit scary at first. In the image just below, I collapse the collections to be able to emphases the visibility of the three prime elements: parameters, variables, and resources.

jsonTemplate

We already know parameters, so let's jump the variables. This section contains a list of key pair value like: imagePublisher, vmSize, virtualNetworkName, diagnosticsStorageAccountName, etc. Those can be fixed value or dynamics by using other variables or parameters. Here some example:
    "vmSize": "Standard_A2"
    "vhdStorageName": "[concat('vhdstorage', uniqueString(resourceGroup().id))]"
    "virtualNetworkName": "[parameters('virtualNetworkName')]"

Last section but not least: the resources. This is where everything is put together to build the solution you will deploy. The resources are defined by specifying their type, name, and properties. You can assign any value from a static string, parameter value or a variable value.

Now that we know it works, why should we use it


Explain all the advantages to use ARM template could be a post by itself, and go further of the scope of that post. However, here few reasons:
  • A template file is light and easy to keep in a repository.
  • It's very simple to have the exact same template deployed in multiple environments.
  • ARM templates are really fast to deploy.
  • Easy to edit/ customize/ expand.
  • Easy to delete.

In Video Please


If you prefer, I also have a video version of this post.



What's Next


This post was voluntary very simple to be easy to understand. Now it's your turn deploy a modest schema or something more complex. Many different templates can be found at various places: Visual Studio, Azure Arm Git Template, and Azure Quickstart Templates. Great tools exist also to help you to visualize or edit these templates: Azure Resource Explorer and Download Azure Resource Manager Tools for VS Code

Resources:

~ Frank


Reading Notes #225

Postman Cloud


Programming


Databases


Reading Notes #180

Quebec, Canada weatherSuggestion of the week


Cloud


Programming


Miscellaneous


~Frank B.


Reading Notes #157

microsoftazurewebsitescheatsheetSuggestion of the week


Cloud


Programming

  • Inception-Style Nested Data Formats (Scott Hanselman) - What seem to be a good solution at one point could put you in a big problem tomorrow. This post explains one possible cause.

Database


Miscellaneous

  • Markdown Style Guide - This post gives some simple tips to keep our Markdown document easy to read when not converted.

~Frank


Reading Notes #136

 

Suggestion of the week


Cloud


Programming


Miscellaneous