How Do You Troubleshoot Azure Template Files?

Problem scenario
You are having problems with your ARM templates (the .json files).  You want to learn more techniques at troubleshoot ARM templates. What should you do?

Possible Solution #1   Follow these directions on Microsoft’s website.
(You will need to download a .psm1 file and use the import-module command in PowerShell.)

Possible Solution #2
Clone this Git repo and use it to validate your ARM templates:  https://github.com/Azure/azure-arm-validator

Possible Solution #3
Substitute any very sensitive data from the JSON with dummy (fake or random) data. 

How Do You Troubleshoot the kubectl Error “Access denied status code: 403”

Problem scenario
You run a kubectl command but you get this error:

“could not get token: AccessDenied: Access denied
        status code: 403, request id:
Unable to connect to the server: getting credentials: exec: exit status 1″

What should you do?

Solution
The root cause is likely that your .kube directory has an incorrect configuration file. 

Possible Solution #1
If you are not using Amazon EKS,

How Do You Create the PowerShell Script, the Template.json and the Parameters.json Necessary to Utilize ARM?

Problem scenario
To use ARM templates you know know you should have three text files: 1) a PowerShell script 2) a template.json file and 3) a parameters.json file.

How do you create these for a given resource (e.g., a storage account, VM, or Function App)?

Solution
1.  In the Azure Portal web UI, start the process of creating a resource.  Right before you click “Create”,

How Do You Use an ARM Template to Create an Azure Serverless Function App?

Problem scenario
As a proof-of-concept you want to use an ARM template to create an Azure Function that uses Azure storage.  You want the template to create the Azure storage account as it is a dependency of the Azure Serverless Function (also known as an App Service).  How do you do this?

Overview
This will create an Azure Function also known as an App Service. 

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 Create the Pound Sterling Symbol (aka the GBP Symbol) £ when You Are Using a U.S. Keyboard?

Problem scenario
You type emails or type text in Notepad or Wordpad (e.g., in Windows).  Sometimes you use a web browser in Windows.  You want to create this symbol £.  What do you do?

Solution
Hold the “Alt” key and type “156” (with no quotes).

How Do You Troubleshoot the SonarScanner Error “java.lang.IllegalStateException: Failed to create lock in /opt/app/sonar-scanner/conf/…sonar_locak…DirectoryLock…”?

Problem scenario
You try to run sonarscanner from a command prompt.  But you get this message:

“java.lang.IllegalStateException: Failed to create lock in /opt/app/sonar-scanner/conf/…sonar_locak…DirectoryLock…”

What should you do?

Solution
Become a different user to run the sonarscanner command or use “sudo ” before your command.

How Do You Find the Data Type of a Variable in an Ansible Playbook?

Problem scenario
Through the register keyword you assign a variable.  You want to know what variable type it is (e.g., a string, a dictionary or a JSON).  You know the data type is not a Boolean.  What do you do?

Solution
If you have a variable (e.g., foobar) and you want to know what data type it is, do this:

debug:
  msg:
when:  foobar.stdout == “”

The playbook will tell you if foobar is a dictionary with an error. 

How Do You Troubleshoot an Ansible Error about a User Not Being Able to Authenticate when the Module is Supposed to Interact with a Database?

Problem scenario
You have an Ansible module that uses a database module.  When you run the playbook, you get an error about a user being unable to authenticate when this database module is run.  What could be wrong?

Solution
Is the user in the error message a user that is created via the playbook?  If it is, does that user get assigned a password?