0

I created a test ASP.NET Core web app and published it to azure via Web Deploy...

When I try to access a page controller via the site URL, I have the following: enter image description here

I have mainly non-modified by default enter image description here also a lauchSettings.json file with

{
    "iisSettings": {
        "windowsAuthentication": false,
        "anonymousAuthentication": true,
        "iisExpress": {
            "applicationUrl": "http://localhost:23403/",
            "sslPort": 0
        }
    },
    "profiles": {
        "IIS Express": {
            "commandName": "IISExpress",
            "launchBrowser": true,
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            }
        },
        "IIS Express (Staging)": {
            "commandName": "IISExpress",
            "launchBrowser": true,
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Staging"
            }
        },
        "IIS Express (Production)": {
            "commandName": "IISExpress",
            "launchBrowser": true,
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Production"
            }
        },
        "MyApplication": {
            "commandName": "Project",
            "launchBrowser": true,
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },
            "applicationUrl": "http://localhost:23404"
        }
    }
}

What should I do in order to modify the ASPNETCORE_ENVIRONMENT variable when publishing it via enter image description here

PS.

I updated the App Settings in Azure portal, like this enter image description here then republished the application...

But nothing changed, I have the same Error...

2

2 Answers 2

2

launchsettings.json only affects local development I think. It won't affect it in Azure. I think you should be able to define an app setting with key ASPNETCORE_ENVIRONMENT set to e.g. Development.

Sign up to request clarification or add additional context in comments.

6 Comments

I updated the App Settings in Azure portal, like in my edit of the OP, then republished the application... But nothing changed, I have the same Error...
Hmm, that's odd. I'll have to try this in a moment.
I put that value in "Development" and now I have an error... Because it can't find my secrets in Azure :) Where by the way I should store that secrets?
haha ! I put them in the Application Settings and that worked !
however is strange that it works only in "Development" mode, probably because of if (env.IsDevelopment()) { builder = builder.AddUserSecrets<Startup>(); }
|
0

I thinks you are mixing 2 questions here.

  1. Deployment to production
  2. Monitoring bugs

As about deployment, it looks like you did everything correctly - your site is hosted using not Development environment. This is exactly what error page tells you.

As about bugs, you definitely would not like anyone to see your connection strings or anything else an error message may contain. So you need to add some logging to see what really fails.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.