How to enable Swagger UI in Azure Easy API - node.js

I'm using Azure App Services and have setup the Easy API with Easy Table for the API backend for my mobile.
I was wondering how can I setup the Swagger UI for the Azure App Service.
When I try to navigate to the API (e.g. https://xxxxxx.azurewebsites.net/swagger/ui), it is stated that "To access the swagger UI, you must enable swagger support by adding swagger: true to your configuration and installing the swagger-ui npm module"
How do you exactly add the swagger-ui npm when you don't have the source to the API (it's created automatically using Easy API) ?

Two parts to your question:
1) Enabling Swagger on EasyAPI is not possible right now. That is to say, we don't merge nor generate the Swagger for EasyAPI as all the parameters are defined in code.
2) If you want to enable Swagger, then you need to add 'swagger: true' to the initializer for Azure Mobile Apps in the app.js file at the level above your API. Go into Easy API or Easy Tables and edit any API/Table. This will bring up the editor. Go to the directory above (the one that contains the api and tables directories) and edit the app.js file there.

Steps:
On Portal Azure
Open your-application App Service
Go to Development Tools -> App Service Editor (Preview) - click GO
Inside App Service Editor (Preview) -> Open Console ( CTRL + Shift + C )
Type npm install --save swagger-ui
Waiting install
Check install if exists folder on node_modules -> swagger-ui
Now enable swagger on application file /wwwroot/app.js
Change content:
var mobile = azureMobileApps({
// Explicitly enable the Azure Mobile Apps home page
homePage: true,
// Explicitly enable swagger support. UI support is enabled by
// installing the swagger-ui npm module.
swagger: true
});
Test Swagger on https://your-application.azurewebsites.net on Google Chrome click try it out or open https://your-application.azurewebsites.net/swagger/ui

Related

Deploy multiple spartacus storefronts?

Is it possible to deploy multiple spartacus angular projects on Commerce Cloud?
I have two Spartacus project and want them both accessible to users. However currently they are deployed to the root and the second one overwrites the first.
This SAP support article has the answers: https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/b2f400d4c0414461a4bb7e115dccd779/1c26045800fa4f85a9d49e5a614e5c22.html?version=v2105
You just need to make sure that you match the manifest.json app name with the output in angular.json outputPath, then you can set the routing in CCV2 by setting properties as followed:
Configure all endpoints to point to the JS Storefront service.
www.brand1.com → Javascript Storefront
www.brand2.com → Javascript Storefront
Configure endpoint-to-storefront mapping in JavaScript storefront service properties.
In the Cloud Portal, choose your environment, then select Service Configuration View configurations JavaScript storefront.
Add your properties in the following format: jsapps..severname.=.
For example:
jsapps.app1.servername.1=www.brand1.de
jsapps.app2.servername.0=www.brand2.com

Azure API management not listing all endpoints\methods

I created an .NET Core based rest API. Then I containerized the application and hosted it over Azure App Service. I was able to see various controller and endpoints using Swagger. I was able to make request and I was able to receive response.
Then I created an Azure API management resource and added this App service as API. After the deployment, all the methods are empty. I do not see any endpoints. What can I do to fix this issue ?
I added the API to Azure API management by following steps:
Under API Management > APIs
Add API
Select app Service
In the pop-up browse for App Service & provide display name, name, API URL suffix and click Create.
You have to install swashbuckle to your app service application so your app service returns a configuration endpoint where apim can find the open api spec or the swagger definition of your Apis and use it to import the Apis to apim
Assuming you use .Net Core, you have to install these packages
and insert the below line of code in your startup.cs (The Configure Method)
app.UseSwagger(options =>
{
options.SerializeAsV2 = true; // this is optional to control the swagger version
});
app.UseSwaggerUI(); //optional

How to replace Open api spec in Azure Api Management service

I have a rest api with its specification written in OAS 3.x version.
This api spec yaml file has been uploaded into Azure Api Management service
Now I have added additional endpoints to this OpenAPI spec and I need to upload it again into Azure Api Management service
Now when I login to Azure >> API Management service >> I can see a list of api .
Next to my api ( whose spec I want to upload can see three dots )
When I click on it I get multiple options one being :import IMport open api spec :
This is where I am confused .. which option should I be selecting ?
I simply need to update existing api specification with the new one ( with additional new endpoints )
I think I should be selecting Update but not quite sure ...
If you are facing issues with update, there is an alternate way. Go to your API and select 'All Operations' there you have an Open API specification editor. You can just replace your code there (copy/paste).

How to enable extensions on an Azure App?

I have activated an app service and a mysql database on microsoft azure.
What I would like to do now is activate the phpmyadmin extension in order to use it for database management.
The problem is that the Extensions item is always disabled from the Azure app service menu.
Following online directions I successfully created a new mysql connection string using this format:
Database=DBNAME;Data Source=MYSQLHOST;User Id=USERID;Password=PWD;
Despite this, the Extensions item is still disabled.
I have also restarted the app but nothing has changed.
Following the path advanced tools > go for the kudu I get this:
https://ibb.co/txKDCPY
If the Extensions on the App Service menu is greyed out, you could go to the Kudu site to add the extension you want.
On the App Service menu, choose Advanced Tools, click Go. You will see your app's Kudu site, on the top of the bar , you could find the Site extensions. Then choose Gallery and search the extensions you want like phpmyadmin. Then you could clike the + button to install the extension.
Update: msdn answer
From your description, it might be that you are using a linux web app. As such, the phpmyadmin is installed as part of the docker image.
To load phpmyadmin you should visit /phpmyadmin.
The credentials are available under the application settings on the web app itself.
More details : https://blogs.msdn.microsoft.com/appserviceteam/2017/06/07/mysql-in-app-feature-for-web-apps-on-linux/

Azure endpointName.azureedge.net error

Azure endpointName.azureedge.net created successfully but while accessing Endpoint url it show error
You do not have permission to view this directory or page.
Did I need to add Custom domain to work it out.
Please guide me.
Which endpoint do you add in Azure CDN profile? If adding Azure web app as its endpoint, which language do you use to develop your web app? From my experience, Please try to input detailed path in your url, for example https://endpointName.azureedge.net/default. We can also set default page at Azure web app Application settings like below screenshot:
Build your solution in release mode
Try to publish it with using publish option of project then check

Resources