You'll need to install the following pre-requisites in order to build SAFE applications
- .NET Core SDK 5.0 or higher
- Node LTS
You'll need to following Azure resources provisioned (these get created automatically by runing dotnet run Azure
):
- An Azure Storage account with:
- a container called properties.
- a table called postcodes.
- An Azure Search instance with:
- an index created via
Management.createIndex
. - a data source created via
Management.createBlobDataSource
. - an indexer created via
Management.createCsvIndexer
.
- an index created via
- Postcodes should be inserted into table storage before properties are imported
-
The fastest way to import these is to use AzCopy 7.3 - (Windows only) then run the following command:
AzCopy.exe /Source:https://compositionalit.blob.core.windows.net/postcodedata /Dest:https://{YOUR_STORAGE_ACCOUNT}.table.core.windows.net/postcodes2 /DestKey:{YOUR_ACCESS_KEY} /Manifest:postcodes /EntityOperation:InsertOrReplace
-
Alternatively you can use Azure Storage Explorer - (Windows, Mac, Linux) and do the following steps.
- Connect to https://compositionalit.blob.core.windows.net/postcodes, which contains a CSV representation of all postcodes.
- Download the
postcodes.csv
file - Connect to your newly created table storage account and the table called
postcodes
- Import the
postcode.csv
file
-
Before you run the project for the first time only you must install dotnet "local tools" with this command:
dotnet tool restore
Set the names for web app, Azure Search, and storage instances, as well as the path to AzCopy in Build.fs:31-34. Navigate to the folder containing the code (e.g. C:\safe-search-3\) and run the following command to deploy the app to Azure:
dotnet run Azure
The first time you do the deployment it will automatically populate the postcodes and properties (this may take a while).
Requirements:
- This requires an Azure Search instace deployed to Azure
- Azurite set up locally
You should also set the following config settings either as environment variables or in user secrets
{
// Azure Search resource name
"searchName": "my-azure-search",
// Azure Search access key (Search service > Keys > Primary admin key)
"searchKey": "MYSECRETKEY",
// Azure Storage account connection string
"storageConnectionString": "DefaultEndpointsProtocol=https;AccountName=mystorageaccount;AccountKey=MYSECRETKEY"
}
To concurrently run the server and the client components in watch mode use the following command:
dotnet run
Then open http://localhost:8080
in your browser.
The build project in root directory contains a couple of different build targets. You can specify them after --
(target name is case-insensitive).
Finally, there are Bundle
and Azure
targets that you can use to package your app and deploy to Azure, respectively:
dotnet run -- Bundle
dotnet run -- Azure
If you want to know more about the full Azure Stack and all of it's components (including Azure) visit the official SAFE documentation.
You will find more documentation about the used F# components at the following places: