Fixed it! It might have been the decoding or the fact that I specified the YAML parameters incorrectly???
- task: PowerShell@2
name: getHCMDefinitionContent
displayName: 'Load File Content - Oracle HCM Internal API'
inputs:
targetType: 'inline'
# script: |
# $content = Get-Content -Path "../sourceArtifact/resources/apimanagement/resources/apis/Oracle HCM Internal API.openapi+json.json" -Raw
# echo $content
# Write-Output "##vso[task.setvariable variable=fileContent;isoutput=true]$content"
script: |
$content = Get-Content -Path "../sourceArtifact/resources/apimanagement/resources/apis/Oracle HCM Internal API.openapi+json.json" -Raw
$encodedContent = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($content))
Write-Output "##vso[task.setvariable variable=fileContent;isoutput=true]$encodedContent"
Then:
steps:
- task: AzureCLI@2
displayName: 'Add API : ${{ parameters.name }}'
inputs:
azureSubscription: ${{ parameters.azureServiceConnection }}
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
# Decode the definitionContent from base64
decodedDefinitionContent=$(echo "${{ parameters.definitionContent }}" | base64 --decode)
echo "Decoded Definition Content:"
echo "$decodedDefinitionContent"
# Use the decoded definition content in the az deployment command
az deployment group create \
--resource-group '${{ parameters.resourceGroupName }}' \
--name 'iac.${{ parameters.apiManagementServiceName }}' \
--template-file '../sourceArtifact/resources/apimanagement/cli/apis/APIM.AddApiFromDefinition.bicep' \
--parameters apimServiceName='${{ parameters.apiManagementServiceName }}' \
--parameters name='${{ parameters.name }}' \
--parameters definitionFormat='${{ parameters.definitionFormat }}' \
--parameters definitionContent="$decodedDefinitionContent" \
--parameters apiPath='${{ parameters.apiPath }}'