Json formatting for debug using powershell, jq and Visual Studio Code

When I’m debugging applications, I usually need to check some JSON responses.

If you only want to see the formatted JSON, you can use jq with PowerShell (BTW I installed jq using chocolatey), running the following PowerShell command in your terminal:

get-clipboard|jq

But usually, I have a considerable chunk of JSON data, and I want to be able to interact with the tree and collapse it.

To do that, I can create a PowerShell script with the following snippet and save it in a folder included in my path and then call it from a PowerShell prompt after copying the JSON to the clipboard.

$clipboardFile = "$env:TEMP\clipboard.json"
get-clipboard > $clipboardFile|code $clipboardFile

For example, I created the file jtoc.ps1 in my c:\windows folder, and I can copy the following JSON to the clipboard {"Hello":"json formatter","Using":"vs code"} and then use jtoc in the terminal and it will open in vs code, then I use ALT+SHIFT+F to format the text.

I hope this was useful and a better way to check your JSON data.

External access to your API in development with Conveyor

In my usual workflow, when I’m developing an API with Visual Studio, and I need to access it from a mobile app, I publish the API to Azure or a local IIS server.
I need to do this because, by default, IIS express publish your API with the localhost endpoint, and it can’t be easily used outside the running machine.
I was looking for a quick fix when I found Conveyor, a Visual Studio extension that automatically provides our API’s external access. Additionally, I created an account on their website to enable public access to my API (outside of the local network).
After installing the extension, it would start when I run my project in Debug mode.
In the following screenshot, you can see which ones are the enabled endpoints.

Enabled endpoints


We can also enable the use of certificates for HTTPS access.
A great addition to my toolbox, easy to install and use 😉

Xamarin.Forms deploy to Android 11 emulator in Windows

I’m usually using the Android emulator while I’m working with VS, and today I was trying to build and deploy to a newly created Android 11 emulator with no luck.

As always, Stack Overflow to the rescue!

In this link, they comment that the problem is that with Android 11 we need a different way of sign the apk.

I didn’t found the option to do it using the UI, so, we need to add the following tag to our Android csproj file for the debug configuration.

<AndroidUseApkSigner>true</AndroidUseApkSigner>

I also needed to disable the use of Shared Runtime and Fast Deployment in the Android project properties

After all the changes, my app is deploying to the Android 11 emulator without issues!

Using Azure Storage Explorer

It’s a free tool to access you Azure cloud storage from your desktop computer.

Install

You can download the installer here.

Run the installer and select to install it only for you, or all users.

Then complete the installation with the default values.

Connection & first run

On the first start, we can select the connection type to our Azure Storage.

Then, we can login with our Azure account to access the storage.

The services available in our storage account depends on the configuration at creation time.

Access to local emulator

If we have configured the local emulator (Azurite), we can connect using the Open Connect Dialog icon.

And then the Attach to a local emulator option.

I have my Azurite instance configured with the default values, so I can connect just setting any Display name.

After confirmation, we can access our local Azurite in the same way that we can access our Azure storage (remember to run your local emulator).

Azure Storage emulator for development in Windows 10

I want to be able to run locally my back end apps that use Azure while I’m working on it.

In the past I used the Azure Storage Emulator but is no longer being supported, Azurite is the new version and in this post I will show you how to install it and start using it.

Install

There are several ways to install Azurite in your development machine like a Visual Studio Code extension, NPM or Docker, we are going to use Docker (If you don’t have it installed, check my post Installing Docker for Windows).

Open a powershell command prompt and use the following command to pull the latest Azurite docker image

docker pull mcr.microsoft.com/azure-storage/azurite

Run

Run Azurite with the following powershell commands

md c:\azurite

docker run -p 10000:10000 -p 10001:10001 -v c:/azurite:/data mcr.microsoft.com/azure-storage/azurite

Now Azurite is ready to be used and you can use your Azure Storage Explorer to access your data or develop your apps.

References

Azurite

Installing Docker for Windows 10

Docker Desktop for Windows is Docker for Windows 10, you can get the installer from here.

I started the installer, and continue using the default options.

After the installation is completed (reboot required), I needed to download and install the WSL 2 Linux Kernel and reboot again.

One of the advantages of using WSL is that we can now run Hyper-V (I use Hyper-V for android emulators) side by side with Linux containers, this was not possible before when Docker needed to use VirtualBox.

At this point Docker is installed and we can follow the provided tutorial.

To check that everything is working as expected, we can open a powershell window and execute the docker -v command.

Also in the context menu from the docker taskbar icon, we can switch to Windows Containers

And that is all! I hope this was useful and let me know what do you think in the comments!