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...

serge
  • 13,940
  • 35
  • 121
  • 205
  • Possible duplicate of [how to set ASPNETCORE\_ENVIRONMENT to be considered for publishing an asp.net core application?](https://stackoverflow.com/questions/41546943/how-to-set-aspnetcore-environment-to-be-considered-for-publishing-an-asp-net-cor) – rickvdbosch Jul 13 '17 at 13:40
  • 1
    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. – juunas Jul 13 '17 at 13:41

2 Answers2

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.

juunas
  • 54,244
  • 13
  • 113
  • 149
  • 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... – serge Jul 13 '17 at 13:59
  • Hmm, that's odd. I'll have to try this in a moment. – juunas Jul 13 '17 at 14:01
  • 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? – serge Jul 13 '17 at 14:15
  • haha ! I put them in the Application Settings and that worked ! – serge Jul 13 '17 at 14:21
  • however is strange that it works only in "Development" mode, probably because of `if (env.IsDevelopment()) { builder = builder.AddUserSecrets(); }` – serge Jul 13 '17 at 14:22
  • Ahh right! :D It won't find user secrets then :) Might have been easier to configure the developer exception page middleware to be used regardless of environment.. – juunas Jul 13 '17 at 14:35
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.