apiops: [BUG] Publisher not able to pick configuration for resource names

Release version

4.8.0

Describe the bug

Hi Team,

I am trying to run extractor and publisher to run ApiOps on API management service as described.

My repository looks like: image

For now, we are not using config_files directory for any purpose.

I have changed the publisher code similar to suggested in this previous bug https://github.com/Azure/apiops/issues/197 This is how the changed code looks like:

- task: PowerShell@2
    displayName: Run publisher for ${{ parameters.ENVIRONMENT}} environment
    inputs:
      targetType: "inline"
      script: |
        Set-StrictMode -Version Latest
        $ErrorActionPreference = "Stop"
        $VerbosePreference = "Continue"
        $InformationPreference = "Continue"
        
        Write-Information "Configuration YAML path is $($env:CONFIGURATION_YAML_PATH)"
        Write-Information "Configuration AZURE_RESOURCE_GROUP_NAME is $($env:AZURE_RESOURCE_GROUP_NAME)"
        Write-Information "Configuration API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH is $($env:API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH)"
        Write-Information "Configuration API_MANAGEMENT_SERVICE_NAME is $($env:API_MANAGEMENT_SERVICE_NAME)"
        Write-Information "Configuration COMMIT_ID is $($env:COMMIT_ID)"


        & "$(PUBLISHER_FILE_PATH)"                
        if ($LASTEXITCODE -ne 0) { throw "Running publisher failed."}

        Write-Information "Execution complete."
      failOnStderr: true
      pwsh: true

Below is the output of this part of the code and the logging related to the issue we are facing: 2023-08-22T21:03:09.5659174Z [command]/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command . ‘/home/vsts/work/_temp/17341838-9553-4cca-9e1a-1df9c22a5d5a.ps1’ 2023-08-22T21:03:09.8921081Z Configuration YAML path is /home/vsts/work/1/s/configuration_pub.preprod.yaml 2023-08-22T21:03:09.8931206Z Configuration AZURE_RESOURCE_GROUP_NAME is ACC-APIM-RG 2023-08-22T21:03:09.8937953Z Configuration API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH is /home/vsts/work/1/s/Artifacts 2023-08-22T21:03:09.8944185Z Configuration API_MANAGEMENT_SERVICE_NAME is ACC-APIM-NAME 2023-08-22T21:03:09.8965244Z Configuration COMMIT_ID is 2023-08-22T21:03:10.1649508Z dbug: Microsoft.Extensions.Hosting.Internal.Host[1] 2023-08-22T21:03:10.1650021Z Hosting starting 2023-08-22T21:03:10.2475920Z info: Publisher[0] 2023-08-22T21:03:10.2476556Z Beginning execution… 2023-08-22T21:03:10.2501292Z info: Publisher[0] 2023-08-22T21:03:10.2501908Z Commit ID was not specified, will put all artifact files… . . . . 2023-08-22T21:03:11.5065039Z info: Publisher[0] 2023-08-22T21:03:11.5065610Z Putting backend DEV-FUNCTION-APP… 2023-08-22T21:03:11.5073189Z trce: PutRestResource[0] 2023-08-22T21:03:11.5073670Z Beginning request to put REST resource { 2023-08-22T21:03:11.5074302Z “properties”: { 2023-08-22T21:03:11.5074502Z “credentials”: { 2023-08-22T21:03:11.5074648Z “header”: { 2023-08-22T21:03:11.5074925Z “x-functions-key”: [ 2023-08-22T21:03:11.5075171Z “{{DEV-FUNCTION-APP-key}}” 2023-08-22T21:03:11.5075313Z ] 2023-08-22T21:03:11.5075422Z } 2023-08-22T21:03:11.5075541Z }, 2023-08-22T21:03:11.5075689Z “description”: “DEV-FUNCTION-APP”, 2023-08-22T21:03:11.5075835Z “protocol”: “http”, 2023-08-22T21:03:11.5076300Z “resourceId”: “https://management.azure.com/subscriptions/****/resourceGroups/DEV-FUNCTION-RG/providers/Microsoft.Web/sites/DEV-FUNCTION-APP”, 2023-08-22T21:03:11.5077265Z “url”: “https://DEV-FUNCTION-APP.azurewebsites.net/api” 2023-08-22T21:03:11.5077418Z } 2023-08-22T21:03:11.5078098Z } at URI https://management.azure.com/subscriptions/***/resourceGroups/ACC-APIM-RG/providers/Microsoft.ApiManagement/service/ACC-APIM-NAME/backends/DEV-FUNCTION-APP?api-version=2022-04-01-preview… 2023-08-22T21:03:11.6659360Z crit: Publisher[0] 2023-08-22T21:03:11.6661064Z System.Net.Http.HttpRequestException: HTTP request to URI https://management.azure.com/subscriptions/***/resourceGroups/ACC-APIM-RG/providers/Microsoft.ApiManagement/service/ACC-APIM-NAME/backends/DEV-FUNCTION-APP?api-version=2022-04-01-preview failed with status code 400. Content is ‘{“error”:{“code”:“ValidationError”,“message”:“One or more fields contain incorrect values:”,“details”:[{“code”:“ValidationError”,“target”:“credentials”,“message”:“Property ‘DEV-FUNCTION-APP-key’ not found.”}]}}’.

Expected behavior

  1. All the DEV environment values are replaced with ACC environment values as mentioned in file configuration_pub.preprod.yaml
  2. The publisher run completes publishing correctly and completely.

Actual behavior

It fails because the value for DEV is not replaced with ACC.

Reproduction Steps

Not sure how to reproduce.

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 28 (14 by maintainers)

Most upvoted comments

@waelkdouh Finally, just now, I could complete the deployment to my first higher environment. Thanks for your support.

@umashankar337 I moved the docs to the following location which should make it easier to locate.

image

You can find it here

@waelkdouh Thanks for quick action.

Frankly from my point of view I am not fully convinced about, if that place is suitable for this information. People might still spend a lot of time before they referred to this FAQ section. But you can change the location of this info later or add in multiple places if more requests coming in I think.

for now, this answers my questions.

It’s really not that complicated. Make sure you look at the extracted artifacts, which typically shows you which properties were extracted so you can easily tell which properties you need to override and the configuration file.