Instead in a .NET Core application in the assets folder you could have .json variables for various environments and just have that environment swappable by an Octopus Deploy variable. This may be needed for Power BI reports wherein all reports across dev, test, and prod have the same base URL and just vary in URL route by way of the gobbledygook of GUIDs in the route. This is not my idea. It comes from a coworker.
Addendum 8/27/2019: The assets folder is in the Angular frontend not the .NET Core app. Duh! Use a trick like this like so... At the top of the file by the imports:
declare var require: any;
const { excelUpload } = require('../../assets/access.json');
Farther downstream in code in a method have:
let powerBIpath: string = ` eq '${fileUpload.FilePath}'`;
if (document.URL.toLowerCase().indexOf("localhost") >= 0){
powerBIpath = <string>excelUpload.dev + powerBIpath;
} else {
if (document.URL.toLowerCase().indexOf("dev") >= 0){
powerBIpath = <string>excelUpload.dev + powerBIpath;
} else {
if (document.URL.toLowerCase().indexOf("test") >= 0){
powerBIpath = <string>excelUpload.test + powerBIpath;
} else {
powerBIpath = <string>excelUpload.prod + powerBIpath;
}
}
}
The guts of access.json are:
{
"excelUpload": {
"dev": "https://app.powerbi.com/reportEmbed?reportId=c9a234a8...",
"test": "https://app.powerbi.com/reportEmbed?reportId=6625dde8...",
"prod": "https://app.powerbi.com/reportEmbed?reportId=c5dcff33..."
}
}
You have to enclose the property names in quotes too or the crawling breaks.
No comments:
Post a Comment