AdminCreds parameter not found in JSON DSC - azure

I'm trying to add an extension to an azure arm template, so when it loops around it adds the extension to each vm, but I'm getting an error where it doesn't recognise the credentials parameter.
The full JSON is at the link below:
https://pastebin.com/embed_iframe/7uvwdZ6e
The error I'm getting is:
VM has reported a failure when processing extension 'CreateADPDC'. Error message: "The DSC Extension received an incorrect input: A parameter cannot be found that
matches parameter name 'AdminCreds'.
Another common error is to specify parameters of type PSCredential without an explicit type. Please be sure to use a typed parameter in DSC Configuration, for example:
configuration Example {
param([PSCredential] $UserAccount)
Any idea where I've gone wrong on this?
Thanks in advance :)

this error comes from your configuration\arm template interaction, if you have the AdminCreds credentials parameter there, i think you need to use protectedsettings to pass it:
"protectedSettings": {
"configurationArguments": {
"adminCreds": {
"userName": "xxx",
"password": "yyy"
}
}
}
configuration should look like this (so should contain adminCreds input parameter with that particular type):
Param (
[System.Management.Automation.PSCredential]$Admincreds,
other_params
)

Related

Azure DevOps Deployment shows InvalidRequestContent: Request content contains one or more instances of unsupported reference property names

We get an error on deploying our Logic-App with Azure DevOps.
I can't explain why this error occurs all at once.
Has anyone seen this error message before?
InvalidRequestContent:
Request content contains one or more instances of unsupported reference property names ($id, $ref, $values) creating ambiguity in paths 'properties.definition.actions.Parse_JSON.inputs.schema.properties.caseId.$ref,properties.definition.actions.Parse_JSON.inputs.schema.properties.integrationId.$ref'.
Please remove the use of reference property names and try again.
Our logic-app contains following JSON-Parse code. Apparently the variable "#/definitions/nonEmptyString" is defined twice.
"caseId": {
"$ref": "#/definitions/nonEmptyString",
"type": "string"
},
Issue reproduced from my end and got expected results.
The issue is with $ref which is not supported by Azure logicapps as mentioned in error got.
Created logic app as shown below and the sample JSON-Parse code is taken as per your requirement
{
"caseId": {
"$ref": "#/definitions/nonEmptyString",
"type": "string"
}
}
By taking $ref got the same error as shown below
Failed to save logic app parselp. Request content contains one or more instances of unsupported reference property names ($id, $ref, $values) creating ambiguity in paths 'properties.definition.actions.Parse_JSON.inputs.schema.caseId.$ref'. Please remove the use of reference property names and try again.
Then removed $ and taken ref in Parse Json as shown and logic App saved successfully without that error and workflow ran successfully.
I have fixed the problem by changing the following code
"definitions":{
"nonEmptyString":{
"minLength":1,
"type":"string"
}
},
"properties":{
"caseId":{
"$ref":"#/definitions/nonEmptyString",
"type":"string"
}
to this code
"properties":{
"caseId":{
"minLength":1,
"type":"string"
}
Maybe the problem was simply that my old solution defined "type": "string" twice. But I have not tested that yet.

Describe DB Instances with AWS Step Function

I've tried to use DescribeDBInstances with AWS Step Function, and these parameters :
{
"DBInstanceIdentifier.$": "$.GetResources.ResourceTagMappingList[0].ResourceARN"
}
When I launch the execution, I have this error :
{
"error": "States.Runtime",
"cause": "An error occurred while executing the state 'DescribeDBInstances' (entered at the event id #7). The Parameters '{\"DBInstanceIdentifier\":\"arn:aws:rds:us-east-2:xxxxxxxxxxxx:db:database-1\"}' could not be used to start the Task: [The field \"DBInstanceIdentifier\" is not supported by Step Functions]"
}
However, the parameter "DBInstanceIdentifier" is referenced in the attached documentation.
https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeDBInstances.html
Can you tell me what's wrong ? And what can I do ?
The only solution I have in mind is to use an AWS Lambda function...
The parameter is DbInstanceIdentifier and not DBInstanceIdentifier.
I found a solution.
If you use the DescribeDBInstances without parameters, you can have all informations about all your instances. You can add a "Pass" block with JSON Path Regex and find what you want.

Get value from json in LogicApp

Rephrasing question entirely, as first attempt was unclear.
In my logic app I am reading a .json from blob which contains:
{
"alpha": {
"url": "https://linktoalpha.com",
"meta": "This logic app does job aaaa"
},
"beta": {
"url": "https://linktobeta.com",
"meta": "This logic app does job beta"
},
"theta": {
"url": "https://linktotheta.com",
"meta": "This logic app does job theta"
}
}
I'm triggering the logic app with a http post which contains in the body:
{ "logicappname": "beta" }
But the value for 'logicappname' could be alpha, beta or theta. I now need to set a variable which contains the url value for 'beta'. How can this be achieved without jsonpath support?
I am already json parsing the file contents from the blob and this IS giving me the tokens... but I cannot see how to select the value I need. Would appreciate any assistance, thank you.
For your requirement, I think just use "Parse JSON" action to do it. Please refer to the steps below:
1. I upload a file testJson.json to my blob storage, then get it and parse it in my logic app.
2. We can see there are three url in the screenshot below. As you want to get the url value for beta, it is the second one, so we can choose the second one.
If you want to get the url value by the param logicappname from the "When a HTTP request is received" trigger, you can use a expression when you create the result variable.
In my screenshot, the expression is:
body('Parse_JSON')?[triggerBody()?['logicappname']]?['url']
As the description of your question is a little unclear and I'm confused about the meaning of I am already json parsing the file contents from the blob and this IS giving me the tokens, why is "tokens" involved in it ? And in the original question it seems you want to do it by jsonpath but in the latest description you said without jsonpath ? So if I misunderstand your question, please let me know. Thanks.
Not sure if I understand your question. But I believe you can use Pars Json action after the http trigger.
With this you will get a control over the incoming JSON message and you can choose the 'URL' value as a dynamic content in the subsequent actions.
Let me know if my understanding about your question is wrong.

Azure Resource Manager template chained functions

I am trying to remove / from the URL using azure function before assigning to output variable value
"webappStorageUri":{
"type": "string",
"value": "[take(reference(resourceId('Microsoft.Storage/storageAccounts', variables('webappStorageName'))).primaryEndpoints.web, length(reference(resourceId('Microsoft.Storage/storageAccounts', variables('webappStorageName'))).primaryEndpoints.web)-1]"
}
Returned value from length function should be the value for take function. This is not working. I get following error on deployment. I don't get anything out of this error message. Does Azure support chained function execution? Is this is right approach to remove / from the URL?
Error message
[error]Deployment template language expression evaluation failed: 'Unable to parse language expression 'take(reference(resourceId('Microsoft.Storage/storageAccounts', variables('webappStorageName'))).primaryEndpoints.web, length(reference(resourceId('Microsoft.Storage/storageAccounts', variables('webappStorageName'))).primaryEndpoints.web)-1': expected token 'RightParenthesis' and actual 'Integer'.'. Please see https://aka.ms/arm-template-expressions for usage details.
I'm not sure what you are trying to achieve, but your function has issues with brackets, and you cannot really substract by appending -1 in a random place.
"[take(reference(variables('webappStorageName')).primaryEndpoints.web,
sub(length(reference(variables('webappStorageName')).primaryEndpoints.web), 1))]"
line breaks for readability only

Azure : How to write path to get a file from a time series partitioned folder using the Azure logic apps

I am trying to retrieve a csv file from the Azure blob storage using the logic apps.
I set the azure storage explorer path in the parameters and in the get blob content action I am using that parameter.
In the Parameters I have set the value as:
concat('Directory1/','Year=',string(int(substring(utcNow(),0,4))),'/Month=',string(int(substring(utcnow(),5,2))),'/Day=',string(int(substring(utcnow(),8,2))),'/myfile.csv')
So during the run time this path should form as:
Directory1/Year=2019/Month=12/Day=30/myfile.csv
but during the execution action is getting failed with the following error message
{
"status": 400,
"message": "The specifed resource name contains invalid characters.\r\nclientRequestId: 1e2791be-8efd-413d-831e-7e2cd89278ba",
"error": {
"message": "The specifed resource name contains invalid characters."
},
"source": "azureblob-we.azconn-we-01.p.azurewebsites.net"
}
So my question is: How to write path to get data from the time series partitioned path.
The response of the Joy Wang was partially correct.
The Parameters in logic apps will treat values as a String only and will not be able to identify any functions such as concat().
The correct way to use the concat function is to use the expressions.
And my solution to the problem is:
concat('container1/','Directory1/','Year=',string(int(substring(utcNow(),0,4))),'/Month=',string(int(substring(utcnow(),5,2))),'/Day=',string(int(substring(utcnow(),8,2))),'/myfile.csv')
You should not use that in the parameters, when you use this line concat('Directory1/','Year=',string(int(substring(utcNow(),0,4))),'/Month=',string(int(substring(utcnow(),5,2))),'/Day=',string(int(substring(utcnow(),8,2))),'/myfile.csv') in the parameters, its type is String, it will be recognized as String by logic app, then the function will not take effect.
And you need to include the container name in the concat(), also, no need to use string(int()), because utcNow() and substring() both return the String.
To fix the issue, use the line below directly in the Blob option, my container name is container1.
concat('container1/','Directory1/','Year=',substring(utcNow(),0,4),'/Month=',substring(utcnow(),5,2),'/Day=',substring(utcnow(),8,2),'/myfile.csv')
Update:
As mentioned in #Stark's answer, if you want to drop the leading 0 from the left.
You can convert it from string to int, then convert it back to string.
concat('container1/','Directory1/','Year=',string(int(substring(utcNow(),0,4))),'/Month=',string(int(substring(utcnow(),5,2))),'/Day=',string(int(substring(utcnow(),8,2))),'/myfile.csv')

Resources