A Node.js command-line tool to fetch appsettings.json from an Azure App Service and output it as a local file. This package makes it easy to retrieve configuration files for local development by interacting with the Kudu API. This is useful when you are not using a centralized configuration service like Azure App Configuration or Azure Key Vault, etc.
- Fetch appsettings.json from a deployed Azure App Service.
- Save the configuration file to any folder on your machine.
- Specify a custom output file name (defaults to appsettings.local.json).
You can install this package globally from GitHub, allowing you to use it from anywhere on your machine.
Example:
npm install -g santrondavenport/azure-appsettings-fetcher
Replace your-username with your actual GitHub username if you're installing directly from the GitHub repo.
To fetch the appsettings.json file from your Azure App Service and save it as appsettings.local.json in the current directory, run:
fetch-config <appServiceName>
<appServiceName>
: The name of your Azure App Service (required).
You can specify a target folder and output file name if you don't want to use the default settings:
fetch-config <appServiceName> [targetFolder] [outputFileName]
<appServiceName>
: The name of your Azure App Service (required).[targetFolder]
: The folder where the output file will be saved (optional; defaults to the current directory).[outputFileName]
: The name of the output file (optional; defaults to appsettings.local.json).
var builder = WebApplication.CreateBuilder(args);
builder.Configuration
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile("appsettings.local.json", optional: true, reloadOnChange: true) // Local development, should be in .gitignore
.AddEnvironmentVariables();
var app = builder.Build();
app.Run();
- Fetch appsettings.json and save to the current folder with default name:
fetch-config my-app-service
This will fetch appsettings.json from my-app-service and save it as appsettings.local.json in the current directory.
- Fetch appsettings.json and save to a custom folder:
fetch-config my-app-service /path/to/target/folder
This will save the configuration file as appsettings.local.json in /path/to/target/folder.
- Fetch appsettings.json and save with a custom file name:
fetch-config my-app-service /path/to/target custom-config.json
This will save the configuration file as custom-config.json in /path/to/target.
- node.js: This tool is built with Node.js, so you need to have it installed on your machine.
- Azure CLI: This tool uses az to authenticate with Azure, so you need to have the Azure CLI installed and be logged into your Azure account.
Run the following to authenticate:
az login
- Fetches an Azure access token using az account get-access-token.
- Uses the token to call the Kudu API for your Azure App Service.
- Saves the appsettings.json file locally in the folder and with the name you specify (or defaults if not specified).
This project is licensed under the MIT License. See the LICENSE file for more details.