When using Azure Functions, the local.settings.json file is usually not checked into the repository by having the default .gitignore file added. This comes quite unhandy when you need to work with several repositories and thus, I’ve collected some commands that do almost all the work required.
Getting started
First, make sure to have the Azure CLI installed.
Now you can login by executing following command in your shell:
az login
Application Insights Instrumentation Key
To obtain the instrumentation key and the AppInsights connection string via cli, you need to install the extension first by executing following command (once):
az extension add --name application-insights
Afterwards, you can obtain the instrumentation key with this command:
az monitor app-insights component show --app <app-name> -g <rg-name>
Reference: az monitor app-insights | Microsoft Docs
CosmosDB Connection String
For retrieving the CosmosDB connection string, the procedure is similar:
az cosmosdb keys list --name <name> -g <rg-name>
oraz cosmosdb list-connection-strings --name <name> -g <rg-name>
Reference:
az cosmosdb | Microsoft Docs (Keys)
az cosmosdb | Microsoft Docs (Connection strings)
ServiceBus Connection String
To obtain the ServiceBus string execute following command:
az servicebus namespace authorization-rule keys list -n "RootManageSharedAccessKey" --namespace-name <sb-namespace> -g <rg-name>
Reference: az servicebus namespace authorization-rule keys | Microsoft Docs
Storage Account Connection String
Last but not least, the storage account access key can be obtained this way:
az storage account keys list -n <name> -g <rg-name>
Reference: az storage account keys | Microsoft Docs
Useful Links: