Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import function via Powershell Az Module #54183

Closed
PhilipAnthonyMurray opened this issue May 6, 2020 — with docs.microsoft.com · 8 comments
Closed

Import function via Powershell Az Module #54183

PhilipAnthonyMurray opened this issue May 6, 2020 — with docs.microsoft.com · 8 comments

Comments

Copy link

A previous question asks around programmatically importing a HTTP Trigger Function App which was never truly resolved. We have our Function Apps hosted within an Isolated tier App Service Plan on a private App Service Environment and at the moment I am unable to expose the OpenAPI specification using the Function App API Definition.

In this particular use case I can manually register a Function App endpoint within APIM but this is not possible on our Pre-Production and Production environments as we have no access. We need a mechanism of completing this task via Powershell and the Az library.

Any assistance would be useful.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@PhilipAnthonyMurray PhilipAnthonyMurray changed the title Toggle issue Import function via Powershell Az Module Import function via Powershell Az Module May 6, 2020
@PhilipAnthonyMurray
Copy link
Author

I used the Dev tools to understand the REST calls in achieving this and there is a chain of 22 calls. This is absolutely not maintainable in a DevOps pipeline.

@mike-urnun-msft
Copy link
Contributor

@PhilipAnthonyMurray Thank you for your feedback! We will review and update as appropriate.

@PhilipAnthonyMurray
Copy link
Author

PhilipAnthonyMurray commented May 29, 2020

@mike-urnun-msft Any update on this functionality?

@mike-urnun-msft
Copy link
Contributor

Hello @PhilipAnthonyMurray - Sorry for the delay in response. I have reached out to the APIM team internally regarding this issue and received confirmation that there isn't a backend endpoint available for this operation at this time around (Portal does it with Javascript on the frontend hence the 22 calls).

As the next step, please consider submitting a feature request on the Azure UserVoice (or upvote an existing one if it exists) for the APIM team to review its priority for the product roadmap.

We will now proceed to close this thread. If there are further questions regarding this matter, please reopen it and we will gladly continue the discussion.

@nnnvvvcv
Copy link

nnnvvvcv commented Jun 1, 2021

@PhilipAnthonyMurray did you ever get anywhere with this? I'm looking to do something similar.

@PhilipAnthonyMurray
Copy link
Author

PhilipAnthonyMurray commented Jun 1, 2021

@nnnvvvcv
We exported the API definition of the Function App as a YAML file then utilised the below Powershell snippet to import into APIM

$apiMgmtContext = New-AzApiManagementContext -ResourceGroupName $ApimResourceGroup -ServiceName $ApiManagementInstanceName

cd $PSScriptRoot
$api = Import-AzApiManagementApi -Context $apiMgmtContext -SpecificationFormat OpenApi -SpecificationPath '.\myYAML.yaml' -Path "myAPIPath" -Protocol Https -ServiceUrl $ServiceUrl

Add-AzApiManagementApiToProduct -Context $apiMgmtContext -ProductId "myProductId" -ApiId $api.ApiId  | Out-Null


@nnnvvvcv
Copy link

nnnvvvcv commented Jun 1, 2021

@PhilipAnthonyMurray thanks for that. Can I just ask what you used to generate the YAML? Was this part of your build pipeline too? I've been looking at the Azure Webjobs OpenAPI library to generate a document but that is generated at runtime rather than buildtime.

I guess we could build the function-app, deploy the function-app, extract the YAML from the running instance and then provision APIM...

@PhilipAnthonyMurray
Copy link
Author

@nnnvvvcv

Not entirely sure, I got the development lead to generate it as a one off. He either had it from the initial spec or generated it from the Swagger editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants