I am trying to use powershell to create an Elastic Job. I can create the job using TSQL with no issues but when try to add a job step it gives error: 'Elastic jobs management operation failed. Cannot reference the credential 'JobExecuteUser', because it does not exist or you do not have permission.' I have not been able to google any occurrences of this error. I know the credential exists because I use the same values in my TSQL code. I am confident my parameter values are correct because I have used them to remove/create TargetGroups and TargetMembers and the job itself.
Here is the code:
Add-AzSqlElasticJobStep `
-ResourceGroupName $ResourceGroupName `
-ServerName $ServerName `
-AgentName $AgentName `
-JobName $JobName `
-TargetGroupName $TargetGroupName `
-CredentialName $CredentialName `
-Name "Deploy CommandLog" `
-CommandText "Do Nothing"