I've configured my az cli to default my resource group, how do I remove/undo that?
az configure --default group=blah
PS C:\Users\blah> az configure -l
[
{
"name": "group",
"source": "C:\\Users\\blah\\.azure\\config",
"value": "blah"
}
]
reference: CLI configuration with az config
re-run the command to set the default w/ no value:
az configure --default group=
PS C:\Users\mdepouw> az configure -l
[]
Related
I'm trying to import a json file into Azure app configuration service using cli command:
az appconfig kv import.
Sample json file
{
"Pss": {
"account/getall/get": "read",
"account/setall/put": "write",
"account/someendpoint/somevalue": "profile"
}
}
I can see below preview in cli
Adding:
{"key": "Pss:account/getall/get", "value": "\"read\""}
{"key": "Pss:account/setall/put", "value": "\"write\""}
{"key": "Pss:account/someendpoint/somevalue", "value": "\"profile\""}
Labels are created as (No label) in app configuration service.
Could you please suggest to me what changes need to be done in the json file to generate label values?
Thanks in advance.
Below command will helps you to get the label name:
az appconfig kv import --name hkappconfig --label testingLabelName --source file --path /home/hari/Import.json --format json --separator . --content-type "application/json
By adding the attribute --label labelName in the Importing az cli command, You will get the label name in the configuration explorer of the app configuration.
Output:
I have the following very simple manifest:
type: install
name: very simple manifest
onInstall:
- log: installing manifest
I can install it from the Jelastic Dashboard. There is an import function in the main menu where I can copy / paste that manifest content and it gets installed. In the Jelastic console, I can see
[15:36:38 manifest.settings]: BEGIN INSTALLATION: very simple manifest
[15:36:39 manifest.settings]: BEGIN HANDLE EVENT: {"topic":"application/install","envAppid":""}
[15:36:39 manifest.settings:1]:> installing manifest
[15:36:39 manifest.settings]: END HANDLE EVENT: application/install
[15:36:39 manifest.settings]: END INSTALLATION: very simple manifest
and the Jelastic dashboard confirms installation.
Now, when I do the same, but via the Jelastic REST API, i.e. using the endpoint
http://my-jelastic-provide.com/1.0/marketplace/jps/REST/install
with the relevant data, then, it doesn't install. Instead, I get the strange error message
Can\'t find environment by domain [jelasticclient-master-0954606]
where jelasticclient-master-0954606 is the envName I set.
However, if I change my manifest to e.g.
type: install
name: very simple manifest
nodes:
count: 1
cloudlets: 4
nodeGroup: cp
image: alpine:latest
skipNodeEmails: true
onInstall:
- log: installing manifest
then it installs perfectly. What am I missing?
I am using Jelastic v6.0.2.
Your "very simple manifest" doesn't suppose any environment name to be passed.
That's why when you pass it you get an error "Can't find environment by domain [domain-name]" (Example1).
When you don't have the "nodes" parameter in the manifest (as in your second example), you shouldn't pass any environment name (Example2) or should pass the existing environment name (response is in Example3).
Example1:
curl -X POST 'https://jca.host-domain/1.0/marketplace/jps/rest/install' \
-d 'envName=jelasticclient-master-0954606' \
-d session=*** \
-d skipNodeEmails=1 \
-d ownerUid=UID \
--data-urlencode 'jps={ "type": "install", "name": "very simple manifest", "onInstall": [ { "log": "installing manifest" } ] }'
The response is:
{"result":11,"response":{"result":11,"source":"JEL","error":"domain [jelasticclient-master-0954606] doesn't exist"},"source":"JEL","error":"domain [jelasticclient-master-0954606] doesn't exist"}
When the environment name is not passed (Example2),
curl -X POST 'https://jca.host-domain/1.0/marketplace/jps/rest/install' \
-d session=*** \
-d skipNodeEmails=1 \
-d ownerUid=UID \
--data-urlencode 'jps={ "type": "install", "name": "very simple manifest", "onInstall": [ { "log": "installing manifest" } ] }'
the response is
{"result":0,"uniqueName":"3c819586-2ef7-4691-9faa-d3059459d20e","response":{"result":0,"uniqueName":"3c819586-2ef7-4691-9faa-d3059459d20e","successText":"","appid":""},"appid":"","successText":""}
When the environment with envName=jelasticclient-master-0954606 already exists, the response of the same request from the Example1 is as this (Example3)
{"result":0,"uniqueName":"b52a8db9-8850-4b66-958a-3dee3345b923","response":{"result":0,"uniqueName":"b52a8db9-8850-4b66-958a-3dee3345b923","successText":"","appid":"7b0c465f6c9573b8d8ce3ed59591781b"},"appid":"7b0c465f6c9573b8d8ce3ed59591781b","successText":""}
In other words, if you pass the environment name when deploying this "very simple manifest" this manifest is installed like an add-on because there is no "nodes" parameter in it but there is no existing environment "jelasticclient-master-0954606" to install this "add-on".
Follwing https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/tutorial-use-custom-image-cli fails here with the error
...
$ az vmss create --resource-group myResourceGroup --name myScaleSet --image /subscriptions/.../myGallery/images/myImageDefinition
Deployment failed. Correlation ID: 6c5f031b-aa0e-42a8-a1d9-faba9b11b208. {
"error": {
"code": "InvalidParameter",
"message": "Parameter 'osProfile' is not allowed.",
"target": "osProfile"
}
}
Any suggestions? You can reproduce this easily using the script https://github.com/dankegel/azure-scripts/blob/main/ss-demo.sh
I can reproduce the error with your script. The problem is that there is a missing "\" after the parameter --image $IDID in your script.
az vmss create \
--resource-group myResourceGroup \
--name myScaleSet \
--image $IDID
--specialized
It should be
az vmss create \
--resource-group myResourceGroup \
--name myScaleSet \
--image $IDID \
--specialized
When I want to exctract the current value of some container env variabe I could use jsonpath with syntax like:
kubectl get pods -l component='somelabel' -n somenamespace -o \
jsonpath='{.items[*].spec.containers[*].env[?(#.name=="SOME_ENV_VARIABLE")].value}')
That will return me the value of env varialbe with the name SOME_ENV_VARIABLE. Pod section with container env variables in json will look like this:
"spec": {
"containers": [
{
"env": [
{
"name": "SOME_ENV_VARIABLE",
"value": "some_value"
},
{
"name": "ANOTHER_ENV_VARIABLE",
"value": "another_value"
}
],
When I want to patch some value in my deployment I'm using commands with syntax like:
kubectl -n kube-system patch svc kubernetes-dashboard --type='json' -p="[{'op': 'replace', 'path': '/spec/ports/0/nodePort', 'value': $PORT}]"
But how can I patch a variable with 'op': 'replace' in cases where I need to use expression like env[?(#.name=="SOME_ENV_VARIABLE")]? Which syntax I should use?
Rather than kubectl patch command, you can make use of kubectl set env to update environment variable of k8s deployment.
envvalue=$(kubectl get pods -l component='somelabel' -n somenamespace -o jsonpath='{.items[*].spec.containers[*].env[?(#.name=="SOME_ENV_VARIABLE")].value}')
kubectl set env deployment/my-app-deploy op=$envvalue
Hope this helps.
Most of them haven't provide proper commands just use as simple as it is =>
kubectl set env deployment/deploy_name APP_VERSION=value -n namespace
op: replace
path: /spec/template/spec/containers/0/env/0/name
value: YOUR_VARIABLE_NAME
op: replace
path: /spec/template/spec/containers/0/env/0/value
value: YOUR_VARIABLE_VALUE
We've created a bash script to rollout our Azure infrastructure based on Azure CLI & ARM Templates.
We also use keyvault to store our secrets and we need to it for references when deploying resources.
Example (this works with static values in the parameters json):
templateUri="armdeploymysql.json"
az group deployment create \
--name $Environment \
--resource-group $RSGName \
--template-file $templateUri \
--parameters #armdeploymysql-parameters.json
In the armdeploymysql-parameters.json you find this:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"administratorLogin": {
"value": "termysqladmin"
},
"administratorLoginPassword": {
"reference": {
"keyVault": {
"id": "/subscriptions/xxx-xxx-xxx-xxx--xx/resourceGroups/resourcegroupname/providers/Microsoft.KeyVault/vaults/keyvaultname"
},
"secretName": "WORDPRESSDBPASSWORD"
}
},
As you can see we are using static values. But we need to deploy this template for multiple environments (Test, Acc & Prod), so we would like to use variables instead of static values.
It works for most of the ARM parameters and we used configure it like:
templateUri="armdeploymysql.json"
az group deployment create \
--name $Environment \
--resource-group $RSGName \
--template-file $templateUri \
--parameters "version=$version" \
"location=$location" \
"administratorLogin=$SQLAdmin" \
"administratorLoginPassword=$SQLPass"
So the question is:
Can we make a parameter reference like the last example to point to a keyvault?
How can we parse variables in the parameters json?
Why don't you use az to get the secret, and then pass it to your template.
WpPwd = az keyvault secret show --vault-name "keyvaultname" --name "WORDPRESSDBPASSWORD"
templateUri="armdeploymysql.json"
az group deployment create \
--name $Environment \
--resource-group $RSGName \
--template-file $templateUri \
--parameters "version=$version" \
"location=$location" \
"administratorLogin=$SQLAdmin" \
"administratorLoginPassword=$SQLPass"
"wordpresspassword=$WpPwd"
Final fix for this specific case (credits to #Murray Foxcroft), snippet from the code:
keyVaultName="keyvaultname-$Environment"
keyVaultsecret="WORDPRESSDBPASSWORD"
SQLPass=$(az keyvault secret show --vault-name $keyVaultName --name $keyVaultsecret --query value -o tsv)
az group deployment create \
--name $Environment \
--resource-group $RSGName \
--template-file $templateUri \
--parameters "version=$version" \
"location=$location" \
"administratorLogin=$SQLAdmin" \
"administratorLoginPassword=$SQLPass" \
The -o tsv was important to avoid adding the extra characters that the normal command passes to the variable.
Thanks for the help!