A batteries included template for kick starting a C# Azure Functions app that connects with a RavenDB Cloud database backend.
RavenDB is a NoSQL document database for distributed applications offering industry-leading security without compromising performance. With a RavenDB database you can set up a NoSQL data architecture or add a NoSQL layer to your current relational database.
The easiest way to get started with RavenDB is by creating a free RavenDB Cloud account or requesting a free license to download it yourself.
If you are brand new to RavenDB, we recommend starting with the Getting Started guide, the RavenDB bootcamp, or the Try RavenDB experience.
To create a my-project
directory using this template, run one of the following sets of commands:
Clone Command (npx):
npx degit ravendb/templates/azure-functions/csharp-http my-project; cd my-project; git init
Clone Command (Bash):
git clone https://github.com/ravendb/templates my-project; cd my-project; git filter-branch --subdirectory-filter azure-functions/csharp-http; rm -rf .git; git init
Clone Command (Powershell):
git clone https://github.com/ravendb/templates my-project; cd my-project; git filter-branch --subdirectory-filter azure-functions/csharp-http; rm -r -force .git; git init
For more, see Cloning the Templates
To start the Azure Function:
$ dotnet restore
$ func start
Click the "Deploy to Azure" button above to deploy the ARM template for this repository.
You can also manually create an Azure Functions app.
Watch the video walkthrough tutorial or read through the step-by-step guide in the RavenDB docs that covers how to get up and running successfully with this template.
The template uses RavenDB.DependencyInjection to configure RavenDB.
Update the appsettings.json
or appsettings.development.json
files:
{
"RavenSettings": {
"Urls": ["http://live-test.ravendb.net"],
"DatabaseName": "Northwind",
"CertFilePath": "path/to/cert.pfx",
"CertThumbprint": "<cert_thumbprint>" // Optional, Windows-only
}
}
The path to the certificate can be relative to the .csproj
file or an absolute file path.
To store RavenSettings:CertPassword
, you can use User Secrets locally and Azure Settings when deployed.
dotnet user-secrets init
dotnet user-secrets set RavenSettings:CertPassword "<PASSWORD>"
In Azure Portal, add a RavenSettings__CertPassword
app setting.
Specifying the RavenSettings:CertThumbprint
will search the Windows Certificate Store under My\CurrentUser
for the specified certificate.
- In Azure Portal, under Function App "Certificates", upload the
.pfx
with password - Set the
WEBSITE_LOAD_CERTIFICATES
app setting to the thumbprint value - Set the
RavenSettings__CertThumbprint
app setting to the thumbprint value
Optionally you could store the certificate in Azure Key Vault, retrieve the bytes, and build the X509Certificate2
to provide to the DocumentStore.