Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Meni 243 posts 479 karma points
    Feb 07, 2023 @ 07:08
    Meni
    0

    Hi,

    When I used to deploy my Umbraco 7 (and earlier versions of Umbraco), I just opened ftp and copied the files. Of course I was also setup the database.

    With 11 it's little confusing. Is there an easy way to do it ? (I don't want to use the dashboard deployment, Umbraco Deploy, etc. just something simple)

    Here's what I did so far:

    After migrated locally the database from 7 to 11, I imported the .bacpac to Azure and now I have the Umbraco 11 database in Azure.

    So now I have the Database on Azure.

    Then I started to migrate the code locally. It's almost finished - not 100%, but I'd say somewhat production ready (I guess I'll continue to ask here with the remaining code .. ;) ) , so I want to deploy now Umbraco 11 to my hosting (Azure) and then I'll push more updates and fixes to the code.

    I also setup a git repository, so now all the local development is with git, so I can setup ci/cd with gitlab / azure, etc.

    My understanding from the docs that the ci/cd is only for the code? (views , partial views, etc.) But what about the other files (bin, umbraco, wwwroot, properties, etc.)?

    How do I deploy the other stuff ?

    Also, it says in the documentation:

    The corresponding .uda file for this Document Type is now updated with the changes - the file is located in the /umbraco/Deploy/Revision folder. You've also created a new Data Type that's used on the Document Type. This Data Type is stored as a new file in the /umbraco/Deploy/Revision folder as well.

    I didn't find the .uda file and not the Deploy/Revision folder

    I tried just to copy-paste my local Umbraco 11 folder (bin, umbraco, etc.) to the ftp but it didn't work. So I brought the Umbraco 7 again (I have now two databases in my Azure - the 7 and the 11).

    So let's say I setup the ci/cd so I can manage the code with git bash, but what about the files, connecting the database I already imported to Azure, etc?

    Please advise.

    Thanks.

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    Feb 07, 2023 @ 08:31
    Kevin Jump
    3

    Hi Meni,

    Yes its a little different with .net core sites than it was with Umbraco 7/8 but once you get your head around it its not to bad.

    The Long answer ...

    How it works

    There are many ways to deploy a .net site but underneath they are all performing a dotnet publish on your site and then copying the resulting files to the webserver.

    a dotnet publish builds your site does a couple of internal things and then copies the resulting files to a publish folder, which is the site. it looks a little weird when you are use to .net framework as all the dlls are in the root of the site ! .

    An example of a published folder

    at the simplest level you can then copy this folder to your webserver and your site startup.

    tip - if you are using azure, and have visual studio there is a publish option when you right click on your site and you can do this on one step.*

    DB Configuration

    Your Database connection is configured in appsettings.json. If this is pointing to a local database you will need to update this before the files get onto the 'live' server.

    the best way to do this is by using a appsettings.production.json file or similar.

    .net will "merge" settings files based on the ASPNETCORE_ENVIRONMENT variable. locally this is usually 'development' and when you deploy to azure it will be set to 'production'

    So while you are developing appsettings.json and appsettings.deveploment.json are merged and on live appsettings.json and appsettings.production.json are merged

    tip: again there are otherways to set this, you can set an enviromental variable that replaces the appsetting, and vistual studio or CI/CD can set things as the site is deployed to the server

    Umbraco bits.

    As you have seen, the Umbraco docs alude to umbraco/deploy/revision folder for your document type changes, but unless you have Umbraco deploy installed you are not going to see that folder. however (shameless self promotion) the uSync package also does this and is free.

    if you install uSync on your site it will create a uSync folder at the root of the site (and it will also be there when you publish). that forms part of the site deployment.

    when the site runs up on the live server you can either configure it to import the settings as the site starts up or you can go to the usync dashboard and import everything off disk.

    this will then mean any changes to datatypes,doctypes, etc will be imported onto your newly deployed site.

    The "Simple" answer

    • If you are not using CI/CD - Visual Studio's 'Publish' menu option wraps quite a bit of this up for you and you can publish the site to an azure web app quite quickly.

    • use uSync if you want to sync datatypes, doctypes etc. as it will keep track of that stuff for you.

  • Meni 243 posts 479 karma points
    Feb 07, 2023 @ 20:19
    Meni
    0

    Thanks for the detailed answer. So if I understand you correctly, in Umbraco 11 it’s kind of, for example, Angular app that you can’t just copy paste the folder, but first need to do ng build —prod? And only copy the dist folder to the ftp?

    If the answer is yes, is there an option to build Umbraco 11 using the command line only and without VS? (Something like dotnet build, etc? You mentioned in your answer dotnet publish - is it the comparable of ng build —prod?)

    “the best way to do this is by using a appsettings.production.json file or similar.” - if I create appsettings.production, then I don’t need on the ftp appsetting.json? Or do I need both?

    Thanks :)

  • Huw Reddick 1702 posts 5999 karma points MVP c-trib
    Feb 08, 2023 @ 08:28
    Huw Reddick
    101

    from the command line you can do dotnet publish

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    Feb 08, 2023 @ 09:02
    Kevin Jump
    0

    Yes,

    As Huw says you can use dontent publish to create the publish folder.

    (docs https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish)

    on its own dotnet publish will build and then publish your site to a 'published' folder. by default this in in the bin folder and will probably be debug so you might want to change that;'

    for example, to build in 'release' and to a folder one level up from your site:

    dotnet publish -c release -o ../published 
    

    (and you can use the dotnet publish command to copy directly to azure if you supply it with the 'publish profile' - this is the file visual studio produces or indeed there is a vs code extension to create them too).

    I have never tried it , so not sure how an FTP to azure will work but in theory it might, but you would need to know which folder all the things went in.

    appsettings files

    You don't need *(and infact shouldn't) delete the appsetting.json file. at runtime asp.net merges the appsettings.json and appsettings.production.json file into one, you site only sees one set of configuration.

    so the "production" file only needs the differences, and indeed things that are in the production file will take precedence over what is in the appsettings.json file so you can use this to override default settings.

  • Caley 14 posts 125 karma points
    Feb 08, 2023 @ 10:05
    Caley
    1

    Hi Kevin / Meni

    Sorry if I'm hijacking this question, but I have a similar question regarding dotnet publish that could complement Menis question.

    Because i'm on a shared host, i'm using the command

    dotnet publish -c Release -r win-x64 -o ./publish-64 --self-contained  
    

    This creates the folder /publish-64 which contents I copy via FTP to the servers www folder.

    That works, but there's a lot of files that needs to be uploaded. My last project was 18.000+ files!

    I know I can edit and upload files directly from Views and wwwroot folder without building first. But when I make a change to one of the .cs files in my local environment, is it then really necessary to upload all files again?

    Partial view of files - there is a lot more

    Partial view of files - there is a lot more

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    Feb 08, 2023 @ 10:18
    Kevin Jump
    0

    Hi,

    You can probably get away with only uploading files that are of a different size that the original. In most FTP clients (e.g FileZilla!) you should see an option like "Overwrite if diffrent size" and then only changed files will be written to the site.

    and most files will not change between publishes,

    if you change a cs file then the "sitename".dll files will change, and when you change views etc the views folder will change.

  • Caley 14 posts 125 karma points
    Feb 08, 2023 @ 10:20
    Caley
    0

    Hi Kevin

    That makes sense. Thanks! :)

Please Sign in or register to post replies

Write your reply to:

Draft