npm i -g azure-functions-core-tools@4 --unsafe-perm true
Open the api.code-workspace
in VS Code.
You will need to install Azurite as a Storage Emulator if using VS Code for API development:
npm install -g azurite
Alternatively, there is an Azurite VS Code Extension:
Open the api.sln
in Visual Studio 2022.
You will also need the Azure Storage Emulator if using Visual Studio 2022 (if you're using VS Code, look above).
Install Azure Storage Emulator
For local development, you can run the Azure Cosmos DB Emulator if you are developing on Windows. If not, you will need to create a CosmosDB instance in your own Azure account. You can use the Azure ComsoDB Free Tier
You will also need to create a SQL API database named 2wr and the following containers:
Container | Partition Key |
---|---|
basekits | /id |
emergencykits | /userId |
hazardinformation | /id |
hazardhunts | /id |
familyplan | /userId |
Alternately, you can run the tool in:
> cd ..\tools\CosmosEmulator
> dotnet run /setup
This will create the database and collections for you.
Create a local.settings.json
file in the TwoWeeksReady project folder. You will need to set the CosmosDbConnection setting to your own CosmosDB instance.
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"OidcApiAuthSettings:Audience": "https://2wrdev.azurewebsites.net",
"OidcApiAuthSettings:IssuerUrl": "https://login.2wr.org/"
},
"ConnectionStrings": {
"CosmosDBConnection": "AccountEndpoint=https://localhost:8081/;AccountKey=YOURLOCALACCOUNTKEY",
"StorageConnection": "UseDevelopmentStorage=true"
},
"Host":{
"CORS": "*"
}
}
In VSCode, you can get a walk-through of the code via the CodeTour extension. Install this extension, and review tours available in the 'CodeTour' folder.
dotnet build
func start --build
F5