context path for java services deployment in jhipster - jhipster

Where to set context path for java services?
I tried contexpath for application-prod.yml as given in Deploying jhipster app to a different context path, but did not work.
Only the context path for rest api after changing is still /api and not /test

Related

Azure Web App for Containers not setting Environment Variables

I have a docker image being deployed from Azure Container Registry. Everything works fine except that I expect to be able to
see environment variables being passed to my running docker image from the Application Settings configured in the portal. It is a Node app accessing environment variables with process.env.VariableName.
As an example its says here
https://blogs.msdn.microsoft.com/waws/2017/09/08/things-you-should-know-web-apps-and-linux/#SetEnvVar …
"App Settings are injected into your app as environment variables at runtime"
I have tried the following.
Setting Applications Settings in the Azure Portal. These are supposed to get passed to the running Docker image as per the documentation but process.env.VariableName in my Node application is not set.
I have tried using a Docker compose file that sets the environment variables but again process.env.VariableName is empty.
I have even updated the VSTS build arguments passing the Variable to my Docker file on build which in turn sets the environment variable. Again no variable passed to the running Docker image.
My conclusion is that custom environment variables are not allowed in Azure Web App for Containers?
Am I doing something wrong?
As per the documentation the app settings are injected into the process as environment variables, however the environment variable name is prefixed with APPSETTING_, so in your Node application you would need to access the app setting with process.env.APPSETTING_VariableName.

Version 4 of Azure App Service Deploy - ERROR_USER_NOT_AUTHORIZED_FOR_CREATEAPP

This is a follow-up question to this question. The answer in the original question helped me, but I am stuck somewhere else. As a reminder, I want to deploy my application using a publish profile. My web app in Azure has two subfolders inside wwwroot and one of them is called backend. I want to deploy my application to that folder. I am not sure why msdeploy wants to create anything, since the web app is already there - I just need to get the artifacts inside the backend folder.
Here is the relevant part of the log (with some names changed to xyz):
2018-06-14T09:19:25.0295238Z Start executing msdeploy.exe
2018-06-14T09:19:25.0323018Z "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:package='D:\a\r1\a\artifacts\drop\xyz.zip' -dest:auto,computerName="https://xyz.scm.azurewebsites.net:443/msdeploy.axd?site=xyz/backend",userName="$xyz",password="***",authtype="basic",includeAcls="False" -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"D:\a\r1\a\artifacts\drop\xyz.SetParameters.xml"
-enableRule:DoNotDeleteRule -retryAttempts:6 -retryInterval:10000
2018-06-14T09:19:25.6154385Z Info: Using ID '89f1210b-39ba-4758-b7ee-76a06407a503' for connections to the remote server.
2018-06-14T09:19:28.0800802Z Info: Creating application (Default Web Site)
2018-06-14T09:19:28.2012951Z ##[debug]rc:1
2018-06-14T09:19:28.2013216Z ##[debug]rc:1
2018-06-14T09:19:28.2013360Z ##[debug]success:false
2018-06-14T09:19:28.2013523Z ##[debug]success:false
2018-06-14T09:19:28.2073234Z ##[error]Failed to deploy web package to App Service.
2018-06-14T09:19:28.2081930Z ##[debug]Processed: ##vso[task.issue type=error;]Failed to deploy web package to App Service.
2018-06-14T09:19:28.2082198Z ##[debug]{}
2018-06-14T09:19:28.2082470Z ##[debug]System.DefaultWorkingDirectory=D:\a\r1\a
2018-06-14T09:19:28.2083178Z ##[error]Error Code: ERROR_USER_NOT_AUTHORIZED_FOR_CREATEAPP More Information: Could not
complete an operation with the specified provider ("createApp") when
connecting using the Web Management Service. This can occur if the
server administrator has not authorized the user for this operation.
createApp http://go.microsoft.com/fwlink/?LinkId=178034 Learn more
at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_AUTHORIZED_FOR_CREATEAPP.
Error count: 1.
I managed to resolve the issue. According to this answer by #starian chen-MSFT, I needed to set the correct parameter in SetParameters.xml. I did this by adding the following to my Visual Studio Build task:
/p:DeployIisAppPath="xyz"
where xyz is the value of DeployIisAppPath element in the publish profile.
The reason is that Azure expecting that site name will be presented twice in scm.azurewebsites.net:443/msdeploy.axd?site=%SiteNameHere%" and the same value as a parameter, by default value from file SetParameters.xml is used for second.
So, you need to modify the value of IIS Web Application Name parameter in xxx.SetParameters.xml programming (e.g. PowerShell or other tasks), after that it should works fine.
Azure staging web deploy fails with ERROR_USER_NOT_AUTHORIZED_FOR_CREATEAPP but not for production

Get Azure App Settings as object using Node?

Is it possible to treat app settings in Azure as an object using Node/Express similar to ASP.NET Core?
For example, if my app settings are:
container:value1 = "Hello",
container:value2 = "World"
I'd like to get an object for "container" that gives me:
{
value1: "Hello",
value2: "World"
}
I've tried container:value1 and container__value1 like ASP.NET Core, but without luck.
Per Azure's documentation,
App settings
This section contains name/value pairs that your web app will load on
start up.
For .NET apps, these settings are injected into your .NET configuration AppSettings at runtime, overriding existing settings.
PHP, Python, Java and Node applications can access these settings as environment variables at runtime. For each app setting, two environment variables are created; one with the name specified by the app setting entry, and another with a prefix of APPSETTING_. Both contain the same value.
So in Node.js, you can use the following line of code to get Azure App Settings.
process.env['container:value1']

System.InvalidOperationException & System.TypeInitializationException from Infer.Net in an ASP.Net Web API 2 in an Azure web role

I have an ASP.Net Web API 2 project. In the controller in a static constructor an Infer.Net model gets initialised. When I run the project locally, either by choosing the web application as the start-up project in Visual Studio 2013 or by choosing the Azure Cloud Service project as the start-up project it works fine, the static constructor runs and the web API calls return the expected values.
However when I deploy the site to Azure and try to call any of the web API controller's methods they fail and I get the exception System.InvalidOperationException with the explanation
An error occurred when trying to create a controller of type 'TwentyQuestionsController'.
Make sure that the controller has a parameterless public constructor.
(It does.)
Looking into the detail of the inner exception the next exception is a System.TypeInitializationException
The type initializer for 'GuessingGamesWebApplication.Controllers.TwentyQuestionsController'
threw an exception
and further down the stack trace I see a System.UnauthorizedAccessException
Access to the path d:\windows\system32\inetsrv\GeneratedSource' is denied
It looks like when I run the project locally the web role process has sufficient privileges for Infer.Net to build and compile the local files that form the model but in Azure the web role process lacks those privileges.
How do I deploy an ASP.Net Web API 2 web role to Azure with sufficient privileges for Infer.Net to build and compile the local files that form the model?
(N.B. I'm using Infer.Net 2.6.41114.1 via NuGet.)
========== EDIT ===========
Looking at this answer to the question Can I write to file system on azure web site? the web role write permissions are limited to the root folder of my app. So an alternative solution would be to configure Infer.Net to write there instead of in d:\windows\system32\inetsrv\. How do I configure Infer.Net to do that?
Got it. I've added the source folder path to the constructor on my Infer.Net model classes:
public LiveDatabaseGamesEngines(string generatedSourceFolder = "MyGeneratedSourceFolder")
{
InferenceEngine.DefaultEngine.Compiler.GeneratedSourceFolder = generatedSourceFolder;
// rest of code...
}
and then in my static constructor in my ASP.Net Web API 2 controller I can pass in the app path:
var generatedSourceFolderPath = HostingEnvironment.MapPath("~/MyGeneratedSourceFolder");
_GamesEngines = new LiveDatabaseGamesEngines(generatedSourceFolderPath);

How can I set the deployment path for an iisApp Provider using MsDeploy?

I am creating Web Deployment Package zip files for my Web Applications
I found I am able to specify the Site Name of the application by including a pubxml during the packaging of my site and using the PublishProfile property during the build to specify that profile.
The pubxml has <DeployIisAppPath>WebSiteName</DeployIisAppPath> in it and that creates the site name as seen in the IIS Management screen.
I'd like to specify the location on disk of the website when it is deployed to a server that doesn't already have this app installed.
What property can I use to do this?
I see that I could use -replace arguments as shown here: Specify different path for provider iisApp when creating package with msdeploy but I would rather the value be set in my pubxml.
You have two options:
Choose the checkbox for "Include IIS settings ...". When you do this a text box will light up with the title "physical Path of web application on destination server". Using the value for the parameter that is generated for this you can modify the destination app path.
Another option for you is to use msdeploy.exe directly and recreate the package using "apphostconfig" provider instead of iisApp provider and then parameterize the application path on the destination server.

Resources