How to use Subnetid parameter with New-AzContainerGroup Powershell Cmdlet? - azure-powershell

I am testing creating an azure container instance group via an automation job which works, but in order to meet my requirements I need it to be attached to one of my configured VNETS, rather than using a public IP.
According to the documentation I need to create a hash table for the subnet ID, which I've attempted to do here, in the $hash variable
Name Value
---- -----
ManagedServices /subscriptions/{My-subscriptionID}/resourceGroups/{My-Resource-Group}/providers/Microsoft.Network/virtualNetworks/{My-VNET}/subnets/{My-Subnet}
However, whenever I run the command attempting to pass the $hash variable in, I receive the following error
New-AzContainerGroup : A parameter cannot be found that matches parameter name 'SubnetId'.
Here is the exact command that I am using
New-AzContainerGroup -ResourceGroupName Dev-Test -Name mycontainer -Image najarramsada/phpipamscanagent -OsType Linux -DnsNameLabel phpipamtest -SubnetId $hash
I am expecting this to run and create a container in my chosen subnet but instead I am getting the error indicating that the parameter doesn't exist. I am also not certain I created my hash table correctly as I've never used them before.

The error message you are receiving indicates that you have spelled the parameter incorrectly.
New-AzContainerGroup : A parameter cannot be found that matches parameter name 'SubbnetId'.
New-AzContainerGroup -ResourceGroupName Dev-Test -Name mycontainer -Image najarramsada/phpipamscanagent -OsType Linux -DnsNameLabel phpipamtest -SubnetId $hash
When creating your hashtable it looks as though you may need to use the following:
$hash = #{
Id = 'resourceId'
Name = 'FriendlyName'
}
Taken from the NOTES section here:
https://learn.microsoft.com/en-us/powershell/module/az.containerinstance/new-azcontainergroup?view=azps-7.3.2#notes

Related

Azure PS command returns empty list

We have created a resource group with a VMSS instance within.
When running the "az vmss list" command within the Cloud Shell, we are able to get the respective resource.
However, when running the exact same command in PS, it returns an empty list, even though the resource exists.
We have also created a different naming convention and used the ARM Api call to test this and we got the same outcome. See the command below:
Invoke-RestMethod -Uri https://management.azure.com/subscriptions/***/resourceGroups/***-nodepool-prd-devtest/providers/Microsoft.Compute/virtualMachineScaleSets?api-version=2020-12-01 -Method GET -Headers $headers -ContentType 'application/json'
Output:
value
-----
{}
We have tried to add another VMSS to the same resource group as a test and noticed that made the other one pop up.
It looks to me as if it is a caching issue but I can't figure out how to resolve it. Any ideas?
Things to keep in mind:
using the same CLI version as Cloud Shell (2.23.0)
running the command from the pipeline returns an empty list
a team member is able to get the resource from their own machine
I saw the similar issue when a specific subscription wasn't show up in a list of output.
We used below ps commands to resolve the issue:
Disable-AzureRmContextAutosave
Disconnect-AzureRmAccount
As you use the Az module, please try these:
Disable-AzContextAutosave
Disconnect-AzAccount
Source: https://github.com/Azure/azure-powershell/issues/6289
PS: it seems you need to edit the title to the "Azure PS command returns empty list"

are there any ansible tower global variables like job id

I am using Ansible tower 3.4.3.
As part of one of my jobs, I need to generate a log file and logfile name should contain Tower_Job_ID to easily recognize which log is generated by which tower job id.
I guess there will be some global variables like "ansible_tower_job_id" but unable to find any documentation or the variable name.
Can some one help, how to capture the current running job ID in ansible tower.
The callback link contains the ID in it.
From the docs: "The ‘1’ in this sample URL is the job template ID in Tower." .

Unable to create VM from existing template using powershell

I am getting below error message when creating VM from existing parameter.json and template.json file.
Code : InvalidDeploymentParameterValue
Message : The value of deployment parameter 'publicIPAddresses_azuse2qaautovm2_ip_name' is null. Please specify the
value or use the parameter reference. See https://aka.ms/arm-deploy/#parameter-file for details.
You need to provide a value for that parameter (in a parameters file) publicIPAddresses_azuse2qaautovm2_ip_name or provide a default value for that parameter.

Need to set part of my PS string as a variable so when it runs it asks for the value

I have tried using the below however what I am trying to achieve is being able to pass this through PowerShell and it asking me for a value for -companyCode.
"\Program Files (x86)\Home\Business Intelligence\ScriptoSql\"ScriptoSqldb1.exe -companyCode="" -sqlserver=SQLSERVER1\INS1,8071 -sqldatabase=StagingDB
Now the command works if I pass a value with it in the string but I want to make it dynamic so when it is called it will ask for that value and it is then entered by the user and the script runs.
Wrap the command invocation in a custom function with a mandatory parameter -CompanyCode. That way PowerShell will prompt for a missing parameter when the function is called.
function Invoke-ScriptToSqlDB {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[string]$CompanyCode
)
& "${env:ProgramFiles(x86)}\...\ScriptoSqldb1.exe" -companyCode=$CompanyCode ...
}
Invoke-ScriptToSqlDB -CompanyCode 'whatever' # pass company code
Invoke-ScriptToSqlDB # prompt for company code

Reference a variable within a variable in JMeter

I'm working with JMeter. I'd like to specify the test host using user defined variables, like this:
variable name value
localhost localhost
test 192.168.0.1
hostname ${localhost}
Executing the test, I see that the hostname value is not substituted, and obviously the test fails. I know I can use properties and pass the hostname from the command line, or simply change the hostname value. Is it possible to it like I've explained?
Thanks.
I've managed to solve my problem. I've changed the hostname variable value to: ${__evalVar(${localhost})}, but I've got this error:
ERRROR jmeter.functions.EvalVarFunction: Variables have not yet been defined
So I've moved the hostname variable declaration in a "User defined variable" child node of my Sampler node. That solved it.
To solve this you should use hostname = ${__eval(${localhost})}
http://jmeter.apache.org/usermanual/functions.html#__eval
Carlos' answer has a mistake (which I can't comment on due to rep) as it uses evalVar, this requires as an argument a plain string:
This works: ${__evalVar(localhost)})
This works: ${__eval(${localhost})}
This doesn't work (the current answer): ${__evalVar(${localhost})}
http://jmeter.apache.org/usermanual/functions.html#__evalVar
Check this forum:
from Blazemeter
For example: getting value of varible "listid_XXX" where the XXX number comes from an index variable:
${__V(listid_${idx1})}
New newer versions (from 2.2), you can use ${__V(${...})}/.
Ex: ${__V(${SERVER_CONTEXT})}/rest
As #Alies Belik mentioned, if you get
ERRROR jmeter.functions.EvalVarFunction: Variables have not yet been defined
then define the 2nd variable in next other UDV (User Defined Variables) node.