My question is pretty specific but I hope someone here will be able to help me...
Okay long story short
I'm developing an Azure Function in C# (with .NET Core 3.1) which outputs PowerPoint slideshows using data fetched from SharePoint lists, and a slideshow template also stored on said SharePoint. To achieve this, I'm using a ConfigurationBuilder
to load the configuration in the local.settings.json
file.
This file pretty much looks like this :
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
},
"TokenEndpoint": "https://login.microsoftonline.com/common/oauth2/token",
"User": "!! put this line filled with the email of the account in your secrets.json !!",
"Password": "!! put this line filled with the password of the account in your secrets.json !!",
"AzureAppId": "some guid",
"SharePointSite": "https://something.sharepoint.com/sites/something_else",
"TemplatesConfig": {
"Path": "Shared%20files/",
"FirstTemplateName": "FirstTemplate.pptx",
"SecondeTemplateName": "SecondTemplate.pptx"
}
To connect to SharePoint, we're using the email and password stored in this file, but to avoid any problems with the credentials leaking, I'm using user secrets that I'm "adding" in the configuration builder to replace the placeholder credentials with actual ones.
Then, I'm going into the TemplatesConfig
items and read the Path
, FirstTemplateName
and SecondTemplateName
properties to know where to search the template files, and the names of the first and second template.
I can run the function locally, everything works as intended. Good.
Where the problems begin
Now, I want to publish the function to the cloud to use it. The function app is created and pretty much set up. I can publish it, but can't run it... And the problem comes from the fact that the configuration builder couldn't read the TemplatesConfig
as it's not defined.
Reading the docs and searching for answers on some forums here and there, I find that the configuration file local.settings.json
is, obviously, only used when executing the function locally and you can't use it when published like I'm trying to. Instead, the key values in this file needs to be input on Azure, in the application settings :
Thing is that the keys entered in the application settings are the keys you could enter in the
Values
item of the configuration JSON, and that's not where my configuration data is... Furthermore, it looks like you can only store key - value associations, but I'm storing a whole item containing these...
According to the documentation, there are multiple sections possible in local.settings.json
, and two of them seem to be linked to the two sections of the page I'm showing you in the screenshot above (Application Settings and Connection Strings), so I think this is the right place to search for answers, but it feels more like I'm going to have to remake my credentials and templates data storing system from the ground up...
It's the first time I'm making an Azure function. In fact, someone else started the job and then passed it on to me when the whole "base" was built (which includes this part of the program which bugs me out because I'm having a hard time understanding it).
So what's my question then ?
Do you have an idea of what I should do to properly store the information about the template, but also the credentials to connect to SharePoint ? Is the current solution correct, or have I completely missed another mechanism I should be using instead to store it ? Should I redo my authentication method completely and use Connection Strings
to connect to SharePoint instead of storing the credentials as keys ?
Thank you so much for your time reading me, and thank you in advance for your replies.