If you haven't read part 1, you should do so before continuing here. Part 1 contains all the prerequisites you need in order to continue with this post.
Navigate to https://devops.azure.com and login to your DevOps account. Create your organization, which is the location in which you will create your projects. In your organization, create your first project:
In the project navigate to the Repos -> Files area, click Import and enter https://dev.azure.com/businesscentralapps/HelloWorld/_git/HelloWorld in the Clone URL field.
Note: The template will constantly be improved and the content of the template repository might vary.
If you want to add multiple apps to the project, the idea is to create folders for each app in the root folder.
After the import, Click the Clone button in the upper right Corner and select Clone in VS Code.
Accept the app change, select a location for the repository and sign in to your Azure DevOps account if asked to do so.
Note: If authentication fails with a NullReferenceException, it is likely because you need to install a new version of the Credential Manager as explained in Part 1.
Open Repository and open settings.json:
Please modify the default profile to match the subscription Id and the Key Vault Name from part 1 of this blog post series. If you are going to create Azure VMs for your Business Central Sandbox environment, you also need to set the Resource Group Name, the Location and the Properties you want to set in the ARM template deployment. The properties section can contain all properties known by the ARM template (described by the template parameter).
Expand the app folder, open app.json, mark <app id>, press Ctrl+Shift+P and select Insert GUID (from the Insert GUID extension we installed in VS Code in Part 1).
Copy the GUID to the clipboard, you need it for the dependency in the Test App. Close app.json.
Expand the test folder, open app.json, replace <app id> under dependencies with the App Id GUID from the App app.json.
Replace the <test app id> with a new GUID. Close app.json.
In this blog post we are primarily working on local builds and local development. For that it is not necessary to checkin your changes.
But, in the next blog post we will be looking at setting up hosted builds and our configuration needs to be in the depot for that.
Click the Source Control icon and press + on the changes line to stage all your changes.
Now enter your commit message and press Ctrl+Enter
In the bottom left side, press the synchronize symbol to push your changes to the depot.
In Part 1, we installed the PowerShell extension in VS Code.
In the repository you will find two scripts for setting up sandbox environments:
Open Local-Sandbox.ps1 and press F5.
Select the current version, login to your azure subscription if asked to do so and wait for the script to complete.
After completion of the script, you should see
Note: That all app folders in the root folder automatically gets a Local Sandbox server created pointing to the local sandbox environment.
Note: In order to create an AzureVM Sandbox environment, you need to correctly configure settings.json as described above (Resource Group Name, VM Name and Contact email for Lets Encrypt)
Open AzureVM-Sandbox.ps1 and press F5.
Select the current version, login to your azure subscription if asked to do so and wait for the script to complete. This will likely take 10-15 minutes and after that you should see:
Note: The deployment is still running inside the Azure VM. The landing page should open automatically and you should see:
This content of this page will change to the landing page when the installation is complete:
Note: That all app folders in the root folder automatically gets a AzureVM Sandbox server created pointing to the AzureVM sandbox environment.
In VS Code, select File -> Add folder to workspace select the app folder in the repository and add this to the workspace.
Do the same with the test folder.
Open your app project in the workspace (not under myfirstapp), click HelloWorld.al
Click the Download Symbols, select appropriate server if you have created both environments (Local Sandbox if running Local, AzureVM Sandbox if running Azure VM). Enter the credentials you stored in the keyvault and you should see:
Press F5 and you should see:
Now we are done setting up our repository, we have build the app and successfully tested it.
In the next Blog Post we will setup build agents and create build pipelines to build the app in Azure DevOps.