Send environment variables to Visual Studio app center using the CLI - visual-studio-app-center

How to I send environment variables for AppCenter builds using the CLI.
I want to send an environment variable such as "TENANT=customer1".
I am using a command similar to:
appcenter build queue -b master
I looked into the "--env" parameter but that seems to deal with the environment of things like API endpoints: https://github.com/microsoft/appcenter-cli/blob/2c7fab9a3dc617c1d6b9b0dd1561d4baf0f50a7c/src/util/profile/environments.ts

Bit late to the party, but found a solution by doing this w/ an API call:
do a GET on https://api.appcenter.ms/v0.1/apps/{owner}/{app}/branches/{branch}/config
copy paste the result, edit the environmentVariables section w/ the desired variables
PUT the updated configuration back to https://api.appcenter.ms/v0.1/apps/{owner}/{app}/branches/{branch}/config
more info about the API Calls can be found here: https://openapi.appcenter.ms/#/build/ and here: https://learn.microsoft.com/en-us/appcenter/api-docs/

Related

Post-build actions in Python/Linux webapp do not run

I have a Django-based web app deployed from Github, running in Python 3.9. The app deploys and starts successfully.
I need to add post-build actions to complete the deployment; the exceeding common Django task of running "manage.py". Following the general and python-specific docs I have added the an app setting of
POST_BUILD_SCRIPT_PATH=postbuild.sh
There is a shell script, postbuild.sh in the root of my app, which runs fine if I SSH into the running container. The expected behaviour is that after deployment, this should run, and output to the deployment log. Neither of these things happen.
I have tested the app setting POST_BUILD_COMMAND with a very simple echo, and that does nothing either.
Can you tell me either what I need to do to make these app settings work, or suggest an alternative method of running the post-build script?
Please note that this is a Linux app using Oryx, so answers concerning Windows/Kudu like this one aren't related.
I noticed you asked your question over here as well. Your setting needs to be set to a relative path, /postbuild.sh.

How to Load Azure App Service Application Settings into VUE?

We have a Vue app hosted as an Azure App Service. Under Settings\Configuration in Azure Portal We have added application settings like VUE_APP_API_ENDPOINT_URL. These become environment variables like the documentation explains, and can be verified by opening a console from the portal and type 'env'.
I Had hoped that These env variables would now be accessible inside Vue by use of
process.env.VUE_APP_API_ENDPOINT_URL
My guess is that its only becomes available in VUE when aplication is build with WebPack or similar.
At least it doesn't work.
Are there any nice way to read those env variables created from Azure App Settings into the vue app?
Some people mentions dotenv npm package, but we need to read the env variables not add them from a config file.
You would be correct that the Environment Variables only become available when you build the application. And to elaborate on that, only the Environment Variables that you specify/supply at build time are the ones that become available in the application from the build process as per the documentation here:
https://cli.vuejs.org/guide/mode-and-env.html#environment-variables
Specifically look at this:
Note that only NODE_ENV, BASE_URL, and variables that start with VUE_APP_ will be statically embedded into the client bundle with webpack.DefinePlugin. It is to avoid accidentally exposing a private key on the machine that could have the same name.
I was struggling to accomplish essentially the same thing that you're trying to accomplish. I was trying to get a value from Azure's Application Settings so that I could setup multiple environments for my application and not have to constantly change values depending on the environment I published the app to.
After realizing that you might be onto something and reading the confirmation of such in the documentation, I decided to try putting the Environment Variable that I was trying to get from Azure's Application Settings in a .env file with a default so that it would be specified at build time. I then published my app to Azure and tested it and it worked!
Try creating a .env file with all of the Azure Application Settings that you're trying to set with default values or something, like:
VUE_APP_API_ENDPOINT_URL=default_value
And then set those same variables into your Azure Application Settings with the proper values and it should work.
Zoull's comment, while somewhat factual, is not possible. His comment implies that setting VUE_APP_API_ENDPOINT in Azure's Static App Settings blade will seamlessly include that var, and perhaps other VUE_APP_* vars into the vue app.
This is wrong.
Webpack is responsible for inclusion of VUE_APP_* vars into the build, and this is only possible at build-time.
This can be verified by following his logic, and then dumping to console "env" at runtime. Values will be set to, permanently, whatever they were at build-time.
tl;dr: Vue will never read, post-build, vars from Application Settings.
I use Github actions to build and deploy. By adding an env: setting after the with: stanza, and including VUE_APP_* vars there, I can do what OP is trying to do.
I believe I can also set some github "secrets" in githubs settings for my repo, and also include them dynamically in the YAML.
Ex. If I have a github secret key/val of: "VUE_APP_FOO: true", in my github action yml, I can do:
env:
VUE_APP_FOO: ${{secrets.VUE_APP_FOO}}
Then, in my final vue build, I should have a value of "true" when I read the process.env.VUE_APP_FOO var.
Savvy?

How could I prohibit anonymous access to my NodeRed UI Dashboard on IBM Cloud(Bluemix)?

I'm working with node-red, on boilerplate IBM cloud. I know that there is a way, changing the value of enviroments variables(NODE_RED_USERNAME and NODE_RED_PASSWORD), to change username and password of the editor flow. But, what about UI dashboard? I mean using dashboard nodes. Forbid access to
https://noderedservicename.mybluemix.net/ui/
I know that on the code, changing the variable httpNodeAuth on the file settings.js I can do what I want. What is the way for doing that on IBM Cloud?
Thank you in advance!
You need to add the httpNodeAuth (not the httpAdminAuth as this is for controlling access to the Node-RED editor and can done with the environment variables discussed in the other answer.) to the app/bluemix-settings.js file.
Something like this:
...
httpStatic: path.join(__dirname,"public"),
httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},
functionGlobalContext: { },
...
Details of how to generate the pass can be found here
There are a number of ways you can edit the file, some of which include linking the Node-RED deployment to a git repository or downloading the whole app, editing the file and pushing it back to Bluemix (when you first deploy Node-RED from the starter pack it gives you instructions on how to download the source to make changes and then push them back. You can get to these instructions by clicking on the "Getting started" link in your Node-RED Bluemix console page).
But the quickest/simplest/dirtiest way is probably to just SSH into the instance and change the file with something like vi. Details on how to ssh to an app instance can be found here. But the following should work:
cf ssh [app name]
Once you have edited the file you will need to tell bluemix to restart the app. You can do this from the web console or with the cf command line tool.
(The changes made by this method will not survive if the app is restaged, or bluemix decides to move your instance to another machine internally because it will rebuild the app from the pushed sources. The permanent solution is to download the source, edit and push back)
This link will help you but it's written in Japanese.
http://dotnsf.blog.jp/archives/1030376575.html
Summary
You can define the "user-defined" environment variables through the IBM Cloud dashboard.
It contains the variables to protect Node-RED GUI.
You have to be set as follows
NODE_RED_USERNAME : username
NODE_RED_PASSWORD : password

controller script running in studio or deployment

Is there a way in a groovy controller script to know is it's running in the studio or in deployment server?
I have code that will added data into the model for demo in studio mode while in deployment that data will come from a REST service call.
Yes there's an easy way to know if a Groovy script is running in authoring (preview) or in delivery (live). Crafter provides a global variable called modePreview. This variable is basically a boolean flag that indicates if the current environment is authoring, or in other words, if Crafter Engine is running in preview mode. So you can do something as simple as if (modePreview) { RUN CODE } in Groovy to run code that only needs to be run in the authoring environment.

How to debug Azure Functions on Azure Portal?

I have created an Azure function. Can i debug Azure Functions on Azure portal without visual studio?
I am passing a complex parameter as File Model, i have to see what's coming in parameter value in debug mode?
There is no debug experience in the portal. Constrained to just the portal, you'll have to use log output to debug.
You might also look into the Azure Functions CLI which provides a local debugging experience. it doesn't require VS.
For Azure Functions V1, you can attach debugger then debug from Visual Studio as the code runs inside csx script:
https://markheath.net/post/remote-debugging-azure-functions
For Azure Functions V2, It seems there is no way till now but you can get massive logs and analytics based on your need.
Or may be you can find a way by uploading the debug version contains (.pdb files) and try to attach debugger. Check this:
https://github.com/Azure/Azure-Functions/issues/872
And i opened an issue here to ask about this:
https://github.com/Azure/Azure-Functions/issues/1051
I have another easiest solution It may feet in your issue or may not, I faced a situation that i want to test azure function webhook but that wouldn't work with localhost so the only solution for me is to test it after publishing and for that i was in need for debug on azure itself but there is another brilliant solution:
You can expose your localhost urls to the public by using many services and for example:
https://localtunnel.github.io/www/
Make sure that you installed nodejs, and follow the instructions to install the localtunel package globally through npm and then you can generate a public url for your localhost webhook so you can verify it against any third party and debug it.
Through Azure Functions Portal you won't able to have debugging tools for do that.
But you can you some ways to debug your azure functions:
1º) Remote debugging using Visual Studio IDE;
2º) Local Debugging using both Visual Studio or VS Code, too;
3º) Event though you're using Azure Functions CLI, you'll need some IDE, that is Visual Studio or VS Code;
The only way that there is on Azure Functions Portal to have something like a debugging is the LOG Window that is localized right below Function Code Window.

Resources