How Do You Create a PowerShell Script to Create a Storage Account in Azure?

Problem scenario
You want to use an ARM template via a PowerShell script to create a storage account in Azure.  How do you do this?

Solution
Prerequisites

1.  If you are using Windows 7, you have installed Azure PowerShell; if you need assistance with this, see this posting.  If you are using Windows 10, you have installed the modules for Azure and the storage resource;

How Do You Install Azure PowerShell on Windows 10?

Problem scenario
You want to run ARM templates to declaratively create resources such as servers, databases, and subnets in Azure.  You need the PowerShell module for Azure to be installed for certain “reserved” words to work.  How do you install the Azure PowerShell?

Solution
1.  Open PowerShell as administrator.  (PowerShellGet is built into Windows 10 by default.  It may appear uninstalled, but it is natively part of the OS.)
2. 

How Do You Troubleshoot “Caught: java.lang.ArrayStoreException: org.codehaus.groovy.runtime.GStringImpl” when running a Groovy Program?

Problem scenario
You are running a Groovy program. 

Here is your code:

def input = System.console().readLine ‘Please provide some input: ‘
def x = input
def boardArray = new String[2]
boardArray[0] = “”
boardArray[1] = “”
boardArray[1] = “$x”
println boardArray[1]

When you run it (i.e., with groovy foobar.groovy), you get this error:

Caught: java.lang.ArrayStoreException: org.codehaus.groovy.runtime.GStringImpl
java.lang.ArrayStoreException: org.codehaus.groovy.runtime.GStringImpl

What should you do?

When Using Jenkins, What Are the Differences between a Declarative Pipeline and a Scripted Pipeline?

Question
In the context of Jenkinsfiles, there are two types of pipelines: declarative and scripted.  What are the differences between these two types?

Answer
1.  The syntax of the two is one difference.  While both are based on Groovy, Declarative Pipeline syntax is more simple (according to this posting).  Declarative Pipeline syntax follows more of an declarative paradigm whereas Scripted Pipeline syntax follows more of a imperative paradigm (according to this posting).

How Do You Troubleshoot “groovy.lang.MissingPropertyException: No such property” when running a Groovy Program?

Problem scenario
You are running a Groovy program.  

Here is your code:

def input = System.console().readLine ‘Please provide some input: ‘
def x = input
def boardArray = new String[2]
boardArray[0] = “”
boardArray[1] = “”
boardArray[1] = $x //this is the incorrect version
println boardArray[1]

When you run it (i.e., with groovy foobar.groovy), you get this error:

Caught: groovy.lang.MissingPropertyException: No such property: $x for class:
groovy.lang.MissingPropertyException: No such property

What should you do?

How Do Quotes Affect Python if Conditional Tests of Equality for a Variable?

Problem scenario
You are programming in Python, and you want to use conditional logic.  You want to know how variables are evaluated and tested.  You want to use the keyword “if” to evaluate a variable assignment.

Solution
This program below shows how the evaluation of a variable in Python behaves when quotes are involved. Errors are not thrown or displayed to the programmer.  Therefore in some instances the programmer must know how quotes affect logical evaluations with variables.

How Do You Iterate through Data Members (the Individual Components) of a Groovy Object?

Problem scenario
You have an object that you want to sequentially pass through.  That is, you want to print either the value or the key/name and value pair of every member data item of the object.  How do you print every individual data member of a given object in Groovy?

Solution
Invoke the “.properties.each” keyword.  This built-in feature will allow you to do just this. 

How Do You Delete Servers in AWS with Python?

Problem scenario
You want to write a Python program to delete servers.  How do you delete EC-2 instances in AWS with Python?

Solution
Prerequisites

a.  You have installed Boto3.  If you do not know how, see this posting
b.  You know the instance IDs.  If you do not know them, see this posting.

Procedures
Read the “Usage instructions” of this Python program we call “deleteec2.py”.

How Are Processes and Threads Different from Each Other in Python?

Problem scenario
You have heard of processes and threads in Python.  Are there illustrative Python programs that use processes and threads to demonstrate the differences between processes and threads themselves?

Solution
Here are two differences between processes and threads in Python:

Difference #1  Children processes keep running when parent process is killed.  Child threads stop processing when parent process is killed.

In a Groovy Program How Do You Assign an Element in an Index to Be the Value of a Given Variable?

Problem scenario
You are trying to write a simple Groovy program.  You have an array of individual strings.  How do you assign one of them to be the value that a variable is?

Solution
To assign an element of an array, should have quotes around the variable and the $ symbol and the syntax ” as String” should follow the closing quote mark.

def input = System.console().readLine ‘Please provide some input: ‘
def x = input
def boardArray = new String[2]
boardArray[0] = “”
boardArray[1] = “”
boardArray[1] = “$x” as String //This is the correct version
println boardArray[1] …