What are the different ways to deploy DAML applications and should we be using all of them?

Great question! Let me go through the options:

  1. This is a ledger-specific thing. Presumably you are using daml-on-fabric here (although you didn’t mention it). The DAML sandbox has something similar where you can pass in a DAR on the command line when starting it. This is convenient when you just want to test something out but as mentioned it is ledger-specific. There is no guarantee that this is possible at all and even if it is possible, the syntax can very from ledger to ledger. Furthermore, it does not help you if you already have a running ledger.

  2. I’ll explain this before 2 since it is the simpler command. daml ledger upload-dar uses the Ledger API to upload a package. Since the ledger API is supported by any ledger, this works against any ledger contrary to 1. It also works against an already running ledger so you do not have to restart your ledger every time you want to upload a new DAR. If you do not pass in the path to a DAR, it will build the DAR for the project you are currently in using daml build and upload that. You can also omit host and port and they will be read from daml.yaml. If you specify host, port and the DAR you can run this command without being inside of a project which is sometimes convenient.

  3. Now on to daml deploy. This is an extension of daml ledger upload-dar. It will first look at your daml.yaml file and read the parties specified under the parties field. For each party, it will then check if there already exists a party with the given display name (it does not check the party id). If it does not yet exist, it will allocate the party with the display name specified in your daml.yaml and the party id hint set to the same name.
    Once it has allocated the parties it uploads the DAR just like daml ledger upload-dar. So daml deploy is just a wrapper around daml build, daml ledger allocate-parties and daml ledger upload-dar. If you want to do all 3, use daml deploy. If not, then use daml ledger upload-dar separately.

5 Likes