To add the tag to the Azure VM we need to use the Update-AZTag command. This command will merge the new tag to the existing tag(s) of the VM. If you are planning to add the entirely new VM tag, you can use the New-AZTag command. Once you use the New-AZTag command, other tags will be deleted for that particular VM and the New tag will be created so pls be careful with that command.We have the VM called TestMachine2k12 on Azure and there are few existing tags applied to the VM as shown below.ExampleGet-AzVM -Name TestMachine2k12 | Select -ExpandProperty ... Read More
In the previous article, we have seen that we can export the Azure resource tags in the JSON file or CSV format. There are some cases when you rebuild your resource and you might need to restore your tags or someone with the authorized person to have azure resource access and he accidentally deletes the tags and we need to restore them. In such cases, if we have the tags backup already we can import them to the resources.In the below example, we suppose we have the Azure VM tags backup stored in the CSV file format and after rebuilding ... Read More
There are two ways to get the applied azure VM tags using PowerShell.Using Tags Property of the Azure VMUsing the Get-AZTag command.ExamplePS C:\> Get-AzVM -VMName Testmachine2k12 | Select -ExpandProperty Tags Key Value --- ----- Patching_Day Sunday Owner ChiragAnother way is by using the Get-AZTag command.PS C:\> $vm = Get-AzVM -VMName TestMachine2k12 PS C:\> Get-AzTag -ResourceId $vm.Id | Select -ExpandProperty PropertiesOutputTagsProperty ------------ {[Owner, Chirag], [Patching_Day, Sunday]}We need to export this tag and the best way to store the tags is using the JSON file.Get-AzVM -VMName Testmachine2k12 | Select -ExpandProperty Tags ... Read More
To add the new tag of Azure VM using PowerShell, we need to use the New-AZTag command. Please note: If you have already tags applied to the VM, you need to use the Update-AZTag command to merge with the available Azure Tags otherwise all the previous applied.For example, We have the below VM called TestMachine2k12 and after signing to the Azure account we need VMs resource ID to apply the tag to the VM.We will use a tag in the HastTable format so we will have its Key and a Value. We need to apply the below new tag.Example$tag = ... Read More
We know that Rust provides a loop keyword to run an infinite loop. But the more traditional way to run loops in any programming language is with either making use of the while loop or the for range loop.While LoopThe while loop is used to execute a code of block until a certain condition evaluates to true. Once the condition becomes false, the loop breaks and anything after the loop is then evaluated. In Rust, it is pretty much the same.ExampleConsider the example shown below:Live Demofn main() { let mut z = 1; while z < 20 { ... Read More
Vectors in Rust are like re-sizable arrays. They are used to store objects that are of the same type and they are stored contiguously in memoryLike Slices, their size is not known at compile-time and can grow or shrink accordingly. It is denoted by Vec in RustThe data stored in the vector is allocated on the heap.ExampleIn the below example, a vector named d is created using the Vec::new(); function that Rust provides.fn main() { let mut d: Vec = Vec::new(); d.push(10); d.push(11); println!("{:?}", d); d.pop(); println!("{:?}", d); }We push the elements into a ... Read More
We know that a process is a program in a running state. The Operating System maintains and manages multiple processes at once. These processes are run on independent parts and these independent parts are known as threads.Rust provides an implementation of 1:1 threading. It provides different APIs that handles the case of thread creation, joining, and many such methods.Creating a new thread with spawnTo create a new thread in Rust, we call the thread::spawn function and then pass it a closure, which in turn contains the code that we want to run in the new thread.ExampleConsider the example shown below:use ... Read More
Use Declarations in Rust are used to bind a full path to a new name. It can be very helpful in cases where the full path is a bit long to write and invoke.In normal cases, we were used to doing something like this:use crate::deeply::nested::{ my_function, AndATraitType }; fn main() { my_function(); }We invoked the use declaration function by the name of the function my_function. Use declaration also allows us to bind the full path to a new name of our choice.ExampleConsider the example shown below:// Bind the `deeply::nested::function` path to `my_function`. use deeply::nested::function as my_function; ... Read More
Unsafe Operations are done when we want to ignore the norm that Rust provides us. There are different unsafe operations that we can use, mainly:dereferencing raw pointersaccessing or modifying static mutable variablescalling functions or methods which are unsafeThough it is not recommended by Rust that we should use unsafe operations at all, we should use them only when we want to bypass the protections that are put in by the compiler.Raw Pointers In Rust, the raw pointers * and the references &T perform almost the same thing, but references are always safe, as they are guaranteed by the compiler to point ... Read More
Whenever we want to remove the tedious long importing paths of functions that we want to invoke, either from the same function or from a different module, we can make use of the super and self keywords provided in Rust.These keywords help in removing the ambiguity when we want to access the items and also prevent unnecessary hardcoding of paths.ExampleConsider a simple example shown below:fn function() { println!("called `function()`"); } mod cool { pub fn function() { println!("called `cool::function()`"); } } mod my { fn function() { println!("called `my::function()`"); ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP