Here are some pointers to resolve issues which you are facing -
- Once you are done with the import, you can use Add-AzApiManagementApiToProduct cmdlet to add product to the imported API. You also need to pass the productid to this cmdlet which you can get from the portal (or you can use Get-AzApiManagementProduct to get all products and choose the one which you need)-
For example -
To set the API product to Starter, you can use the Id - "0123456789" as it appears on Azure Portal.
$Api = Get-AzApiManagementApi -Context $ApiMgmtContext -Name {ImportedApiname}
Add-AzApiManagementApiToProduct -Context $ApiMgmtContext -ProductId "0123456789" -ApiId $Api.ApiId
- Now, unfortunately, the API cmdlets lacks the feature to update the "Subscription Required" Flag to False. Using the cmdlet "Set-AzApiManagementApi" does not work either. However, you can use the below alternative PowerShell code to update the subscription required flag to false.
$Api = Get-AzApiManagementApi -Context $ApiMgmtContext -Name {ImportedApiname}
$Api.SubscriptionRequired=$false ## This will make the subscription flag as false
Set-AzApiManagementApi -InputObject $Api -Name $Api.Name -ServiceUrl $Api.ServiceUrl -Protocols $Api.Protocols
I have tested this and it works as expected.
- Regarding the resource error, which you are getting on Azure Portal, you can use the New-AzApiManagementBackend cmdlet without the -ResourceId parameter while adding the API backend.
$credential = New-AzApiManagementBackendCredential -AuthorizationHeaderScheme basic -Header @{"x-functions-key" = @("{{funcapim-key}}")}
$backend = New-AzApiManagementBackend -Context $ApiMgmtContext -BackendId FuncBackend -Url 'https://funcapim.azurewebsites.net/api' -Protocol http -Title "FuncBackend" -SkipCertificateChainValidation $true -Credential $credential -Description "Function App API Backend"
Once added, the backend will be set with the Runtime URL under the Custom URL properties on Azure Portal and you don't specifically need to update Azure Resource and RunTimeUrl properties as long as the Named values are configured correctly with the function key.
I have tested this with the custom URL and able to call the Azure function API from APIM after importing and following the above-mentioned steps. Please check the below screenshot for your reference.
Hope this helps. Please let me know if you still have any issues and I would be happy to continue the conversation to get you unblocked.
Thanks
Saurabh
Please consider hitting Accept Answer
button. Accepted answers help community as well.