Hi! I am trying to overwrite an existing Api manag...
# azure
w
Hi! I am trying to overwrite an existing Api management Api
policy
in Azure with Pulumi. I have imported the ApiManagement api
azure-native:apimanagement:Api
but when I try to overwrite the policy in my pulumi program I get an error:
Copy code
Type                                     Name                   Status                  Info
     pulumi:pulumi:Stack                      MyService.deploy-dev  **failed**              1 error
 ~   ├─ kubernetes:apps/v1:Deployment         MyService             updated (4s)            [diff: ~spec]
 ~   ├─ kubernetes:apps/v1:Deployment         MyService-servicebus  updated (4s)            [diff: ~spec]
 +   ├─ azure-native:apimanagement:ApiPolicy  apiPolicy              **creating failed**     1 error
 ~   └─ azure-native:apimanagement:Api        MyService             updated (12s)           [diff: ~value]
 
Diagnostics:
  pulumi:pulumi:Stack (c4sservice.deploy-dev):
    error: update failed
 
  azure-native:apimanagement:ApiPolicy (apiPolicy):
    error: autorest/azure: error response cannot be parsed: {"" '\x00' '\x00'} error: EOF
 
Resources:
    ~ 3 updated
    14 unchanged
Here is the policy I want pulumi to use:
Copy code
var policy =
$@"<policies>
        <inbound>
            <set-header name='Authorization' exists-action='override'>
                <value>{apiManagementServiceValue}</value>
            </set-header>
            <base />
        </inbound>
        <backend>
            <base />
        </backend>
        <outbound>
            <base />
        </outbound>
        <on-error>
            <base />
        </on-error>
    </policies>";

    //Policy
    var apiPolicy = new ApiPolicy("apiPolicy", new()
    {
        ApiId = MyServiceApi.Id,
        Format = PolicyContentFormat.Xml,
        PolicyId = "policy",
        ResourceGroupName = apiManagementResourceGroupName,
        ServiceName = apiManagementService,
        Value = policy
    }, new()
    {
        Provider = ElkAzureResourceProviders.GetProvider(),
        Protect = true,
        DependsOn = MyServiceApi
    });
Pulumi plugin: azure-native version 2.3.0 Does anyone have an idea why this is not working? Thanks!
b
does
<value>{{apiManagementServiceValue}}</value>
work?
w
Hi Derek! Thanks for replying. I did wonder about this but found another service we have in house here where this is used, so it works. Also I figured this whole issue out yesterday. I ended up needing to import the api policy to Pulumi (which we had trouble with earlier, but that was because of a fault in our import command.) So when the policy was imported we were successful with overwriting the imported policy in the Pulumi program. The policy was then updated by Pulumi in Azure.