Is it safe to store Azure Function App application settings in a public NodeJS repository?

Is it secure to save secret environment variables in Azure Function App's Application settings and reference them in NodeJS code as process.env.API_AI_ACCESS_TOKEN?

If someone accesses the public repository and runs the code, will they be able to access my Azure resources and incur costs?

Answer №1

  • Storing secrets directly in the application settings of an Azure Function App is not a secure practice.

  • Instead, utilize Azure Key Vault to securely store and retrieve secrets, ensuring that your secrets are encrypted and access is controlled.

Recommended Approach:

1. Enable System Identity in your Function App->Settings->Identity.

  • 2. Create a secret in your keyvault and grant keyvault access to the principal of your function app.

  • 3. Select a template from the dropdown menu and locate your function app's principal in the selection section.

4. Follow the same steps to provide keyvault access to the user.

5. Navigate to Secrets->create a secret and input your secret value.

6. Choose the created secret and make note of the Secret Identifier for adding it as a setting in the function app.

7. Securely access your secret from keyvault in your functionapp by configuring the secret identifier in Configuration-> Add Application settings.

@Microsoft.KeyVault(SecretUri=<your_secret_identifier_Uri**)

8. Retrieve your application settings along with their values in your code using const secret=process.env.secret.

Outcome:

You can also implement this process efficiently by utilizing the Azure Key Vault SDK.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

An issue has been encountered with the Shopify package while trying to create a Client instance

Looking for help with importing the Shopify API from NPM and setting up the client without encountering errors. Here is the code snippet: import Shopify from '@shopify/shopify-api'; const client = new Shopify.Clients.Rest('store_name_here.m ...

Implementing logout in a Node.js and Express application with Auth0: A step-by-step guide

I am currently working with a Node.js and Express server, leveraging Auth0 for authentication. I have been trying to figure out how to enable logout functionality when the client accesses the "/exit" route in my application. Here is an overview of the rele ...

The express gateway is unable to transfer multipart/formdata

I've implemented express gateway as my main service gateway. One of the services I have needs to update an image, and when I try to handle files independently using multer it works fine. However, once this service is routed through express gateway, th ...

core.js:5873 - An issue occurred where the property 'filename' could not be read due to being undefined

My aim is to upload images to my Node.JS server and retrieve them from an Angular client using the provided code snippets: image.ts: export class Image { fieldname: string; originalname: string; encoding: string; mimetype: string; des ...

Check the output of the ChildProcess after executing a shell command

I am currently running the ChildProcess function within a Nextjs API route and I am struggling to retrieve the value from it. const output = exec( "curl -s -v https://test.com/index.php", (err, stdout, stderr) => { if (err) { ...

Comparing JS Async/Await, Promise, and Callbacks: Which is Best

I'm trying to wrap my head around the differences between callbacks, promises, and async/await. While I understand how callbacks and promises work, I'm struggling with grasping the usage of async/await. I know it's essentially a syntactic su ...

What sets apart the following: ( import React from "react"; ) and ( import React from 'react'; )?

When it comes to imports, is there a distinction between using single quotes (') versus double quotes ("), for example in import React from 'react'; and import React from "react";? Are there any notable differences? ...

`MongoDB impatient for query outcome`

Upon trying to pass the 'db' from my server.js file, where I establish a connection with MongoClient, to routes/api.js for post requests, I encountered an issue. The error message I consistently receive is: TypeError: Cannot read property &apo ...

Using the Moment library in a NestJS application

I am integrating momentjs into my nestjs application and I want to ensure that my services can be tested effectively. To achieve this, I have included momentjs in my module setup as shown below: providers: [ { provide: 'MomentWrapper', ...

issue with logging in, token verification failed

My current project involves creating a login system with authorization, but for some reason the token is not being transferred properly. const path = require('path'); const express = require('express'); const bodyParser = require(' ...

Sending a message without any content is not possible

I'm currently working on a unique project with Node JS to develop a discord chatbot that can play the game Connect Four. My current focus is on successfully drawing the initial game board. However, I am encountering an unexpected error: 'Unha ...

Transmitting a custom PDF document through email with React and Node.js

Currently, I am in the process of developing an application designed to streamline the completion of a complex form. The data entered into this form will be stored on a remote database for future reference and editing purposes. Once the form is ready for s ...

The internal cjs loader in node threw an error at line 1078

I'm encountering an error on Windows 10 when running the npm command: node:internal/modules/cjs/loader:1063 throw err; ^ Error: Cannot find module 'D:\mobile-version portfolio\ at Module._resolveFilename (node:internal/modules/cjs/load ...

I'm trying to figure out which one is the correct term on Ubuntu - is it "node" or "nodejs"? And

Trying to install webpack-dev-server but it requires the latest version of nodejs. I am using Ubuntu 20.04 and attempted to update with nvm, which did not work. Following this Q&A answer here, I then tried to install nodejs using sudo apt-get install ...

A TypeError has occurred due to unescaped characters in the request path, caused by [ERR_UNESCAPED_CHARACT

On my Ubuntu system, I am receiving incoming HTTP requests from the URL below: http://<MY-IP>:3000/v1/projects/list Description: The issue I'm facing is that when I make the request, I encounter the following error in the terminal: TypeError [ ...

Storing a reference to a user's login information

Struggling with establishing a straightforward relationship between User and Tweet Schemas. I've implemented a middleware to authenticate users based on their tokens upon login. The issue arises when it comes to saving a tweet for a logged-in user wit ...

How can I verify if the first character is a letter using express-validator?

case 'username': { return [ check( 'content.data.username', 'Username must contain at least one letter' ) // .matches('(?=.*[a-z])(?=.*[0-9])&apo ...

Error: The function callback.apply is not a valid function (Node.js and Mongodb)

Encountered an error when adding the line "{ upsert: true }": Error message: TypeError: callback.apply is not a function // Accessing routes that end in /users/competitorAnalysisTextData // ---------------------------------------------------- router . ...

Asynchronously pushing items to an array and saving with Node.js promises

I am currently attempting to populate an array (which is an attribute in a Mongo Model) with items received from a request. I iterate through these items to check if they already exist in the database, and if not, I create a new Item and attempt to save it ...

Exploring Unanchored Substring Queries in Loopback API

Searching for a solution to implement a basic substring query using the loopback API for a typeahead field. Despite my efforts, I have not been able to find a clear answer. I simply want to input a substring and retrieve all brands that contain that subst ...