https://pulumi.com logo
Title
w

wet-noon-14291

01/12/2021, 3:13 PM
Is there a way to set the name when creating an API in API management through the nextgen sdk with an openapi link? I want to have two instances based on the same openapi spec, but it seems like the name is taken from the openapi spec and I don't find any argument to override it. It is possible in the old sdk so I use that for now, but I didn't find a way to do it in nextgen.
t

tall-librarian-49374

01/12/2021, 3:16 PM
Do you have the Azure NextGen snippet at hand?
w

wet-noon-14291

01/12/2021, 3:57 PM
sure:
module Api =
        open Pulumi.AzureNextGen.ApiManagement.Latest
        let createDefaultArgs apiId path swaggerUrl serviceName resourceGroupName =
            let apiVersion = input "v1"
            let subscriptionRequired = input true

            ApiArgs(
                ApiId = apiId,
                Format = input "openapi-link",
                Path = path,
                ResourceGroupName = resourceGroupName,
                ServiceName = serviceName,
                Value = swaggerUrl,
                SubscriptionRequired = subscriptionRequired
            )
The
Pulumi.Azure.ApiManagement.Inputs.ApiArgs
has a
Name
property that isn't there for Azure NextGen.
t

tall-librarian-49374

01/12/2021, 4:45 PM
Isn’t it the same as
apiId
?
w

wet-noon-14291

01/12/2021, 8:08 PM
ah... it most likely is. I was expecting it to be named something with "name", I think that is what it is called in the UI.
@tall-librarian-49374, on a second thought... I did think I changed that actually, but it didn't reflect a change in the name.
t

tall-librarian-49374

01/12/2021, 8:49 PM
Well, that’s how Azure models there API, we don’t rename parameters. See e.g. https://github.com/Azure/azure-sdk-for-go/blob/master/services/apimanagement/mgmt/2019-12-01/apimanagement/api.go#L49
w

wet-noon-14291

01/12/2021, 9:27 PM
still unclear if apiid is supposed to be mapped to name. Working with APIM hasn't been as straightforward as my previous experience, but I guess that could be because of how things work on azure.
s

some-flower-64874

01/13/2021, 9:27 AM
I suspect that
ApiId
is the name, certainly it appears to map that way for
OperationId
- playing with the Azure CLI the value that comes back in JSON is "name" but the parameters you supply that value to are
xxxId
w

wet-noon-14291

01/13/2021, 3:32 PM
I'll try some more. I do think the APIM bits is really shaky. For some reasons when I deploy I get an error from time to time where it complains about the name being a duplicate, which is strange. The name it refers to is the title in the openapi spec we have, but that should only be used if we don't provide a name I think.