I created an Endpoint Manager Packaging Script (Pt.3) which downloads the installer, packages it, uploads it to Intune and assigns it. But first things first, credits to Nickolaj Andersen and his module who made it all possible.
This is part 3, where we store the package for later use. We use artifacts to do so. In addition, we will update the YAML code to add this to our pipeline.
Prerequisites
Firstly, you need to complete to other parts of this series:
1. Part 1, Endpoint Manager Packaging Script
2. Part 2, Create a packaging pipeline
Download and Install Azure CLI
Next, I have updated the script from my github again. So if you are using a previous version. Please use the link to download it again.
After that, you are ready to start this blog.
Create Storage Account
First, we create a storage account. We need to store our packages somewhere.
We use Powershell to do so.
Firstly, use this code to log on to Azure:
Connect-AzAccount
After that, select the appropriate subscription:
Get-AzSubscription -SubscriptionId "subscription id" | Set-AzContext
Create the resource group:
$RGName = "NielsKokTechTest" $Location = "West Europe" $StorageAccountName = "nielskoktechshared" New-AzResourceGroup -Name $RGName -Location $Location
Lastly, create the storage account:
New-AzStorageAccount -ResourceGroupName $RGName ` -AccountName $StorageAccountName ` -Location $Location ` -SkuName Standard_GRS
This is the result:


After that, create a container in the storage account by using the following code:
$RGName = "NielsKokTechTest" $StorageAccountName = "nielskoktechshared" $ContainerName = "packages" $Key = Get-AzStorageAccountKey -ResourceGroupName $RGName -Name $StorageAccountName $context = New-AzStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $Key.Value[0] New-AzStorageContainer -Name $ContainerName -Context $context
As a result, the container is created:

Uploading the files to the storage account – Endpoint Manager Packaging Script Pt.3
Let’s first try to upload a folder to the storage account. You can do so by using the following code (Using Azure CLI this time):
Firstly, log on to Azure CLI
az login
Select the appropriate subscription:
az account set --subscription "subscription id"
After that, save this code as a .ps1 file:
[CmdletBinding()] param ( [Parameter()] [string] $RGName, [Parameter()] [string] $StorageAccountName, [Parameter()] [string] $ContainerName, [Parameter()] [string] $PackageName, [Parameter()] [string] $SourcePath ) # Get Access Key from storage account $GetKey = az storage account keys list --resource-group $RGName --account-name $StorageAccountName $StorageAccountKey = $GetKey | ConvertFrom-Json az storage blob upload-batch --destination $ContainerName ` --account-name $StorageAccountName ` --account-key $StorageAccountKey.Value[0] ` --destination-path $PackageName ` --source $SourcePath
Test drive this file by using this code (use accordingly ofcourse):
$RGName = "NielsKokTechTest" $StorageAccountName = "nielskoktechshared" $ContainerName = "packages" $SourcePath = "D:\Temp\PackagingTest" $PackageName = "GoogleChrome" .\UploadToStorageAccount.ps1 -RGName $RGName ` -StorageAccountName $StorageAccountName ` -ContainerName $ContainerName ` -SourcePath $SourcePath ` -PackageName $PackageName
As a result, the files have been uploaded:



Adding the script to the packaging pipeline – Endpoint Manager Packaging Script Pt.3
Firstly, you need to update the main script:

You can download it here, from my Github.
After that, you need to add another file to your repository in Azure DevOps. This is the YAML file for the new pipeline which includes the upload to the storage account part. This is the link to the file. Make sure it is availalbe in your Azure DevOps repository:

Next up is a new variable group. We would like to store the variables of the Storage Account in variable group.
Go to Pipelines. After that, go to library:

Create a new variable group:

Name the group and add these variables: (use accordingly to your environment)

It is now time to create the actual pipeline. Go pipelines:

After that click on New pipeline:

Select your repository:

After that, select existing file:

Select the IntunePackaging-WithUpload.yml file:

Save the pipeline!
Running the pipeline
Click here to run the pipeline:

When the pipeline runs, it runs exactly the same in Part 2. After that, this part is added:

When the pipeline finishes the data is available in the storage account:




Check out the other parts also:
1. Part 1, Endpoint Manager Packaging Script
2. Part 2, Create a packaging pipeline
2 thoughts on “Endpoint Manager Packaging Script Pt.3 – Create a library from packages”