Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Is there a property or method which will tell me which Umbraco Cloud environment I'm currently on?
I know I can inspect the url of the current request, etc., but if there's something built in I'd rather use that.
I have code that I use on my own Umbraco Cloud projects, which I started to put together into a package, but never released it.
The code is here: https://github.com/leekelleher/umbraco-cloud-toolkit.
Take whatever code you want from the repo.
There are some MVC view helper methods, e.g. @Umbraco.IsStaging()
or an EnvironmentHelper utility class if needed elsewhere.
Hope this helps.
Ultimately, there's a text file called environment, which is in the parent directory of the website. That contains the name of the current environment.
All the other code in my repo is based around that.
Thanks Lee! I also developed my own simple solution, but will take a closer look at the repo since there seems to be a bit more of value there.
The environment file, is that one which you create manually? I haven't seen it on Local or on Dev env's.
The file will already exist on the environment. If you have access to the Kudu console, the text file will be in C:\home\site\environment.
As for Local, that file doesn't exist - the code in my repo will make some assumptions, e.g. using HttpContext.Request.IsLocal.
Otherwise it assumes it's "Elsewhere" (wherever that may be) :-D
I don't have a file named C:\home\site\environment, but I do have a folder with that name. Inside that folder there's a file named either development or live dependent on which environment I'm in. Is that what you mean?
Yup, that's the one! :-D (I'd forgot it was a folder when I replied last week - it's been a while since I'd looked at it)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted