Install .NET Core on Linux by using an Azure Batch start task
This article describes how to install .NET Core on Linux by using an Azure Batch start task.
Original product version: Cloud Services (Web roles/Worker roles)
Original KB number: 4466812
Procedure
To install .NET Core in a Linux environment, follow these steps:
Go to .NET tutorial to create a shell script named
ex- dotnetcoreinstall.sh
.Note
This link is valid for Ubuntu version 16.04. The script can change, depending on the Linux distribution on which you want to install .NET Core. Select the required Linux distribution and create the script accordingly.
Upload the script
dotnetcoreinstall.sh
to the storage account from which the start task will be downloaded in the Linux VM.Create a Batch pool that consists of the required Linux VM distribution, and edit the Start Task as follows. The Batch Explorer (formerly namedBatchLabs) tool is used to simulate the scenario. The same thing is true in case the pool is created from the portal.
Blob source:https://batchpratyaystorage.blob.core.windows.net/batchcontainer/dotnetcoreinstall.sh
This represents the actual URL of the blob (such as the script).
File path: /mnt/batch/tasks/startup/wd
This represents the local path on the Linux virtual machine where the script will be downloaded from the storage account.
Troubleshoot steps
These steps above work as expected when you create the script in a Linux environment. However, these steps fail and you receive the following error message when you create the script in a Windows environment and upload it to the storage account.
(--install):processing archive packages-microsoft-prod.deb
cannot access archive: No such file or directory
Errors were encountered while processing:
packages-microsoft-prod.deb
] is not understood in combination with the other options.
] is not understood in combination with the other options.
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package dotnet-sdk-2.1.200
E: Couldn't find any package by glob 'dotnet-sdk-2.1.200'
E: Couldn't find any package by regex 'dotnet-sdk-2.1.200'
This behavior occurs because the script in different environments (Windows or Linux) is created in different formats. To determine the format, run the file command in the Linux bash shell. UNIX systems use a single character, the linefeed character, and Windows systems use both a carriage return and a linefeed (often referred to as CRLF) to terminate lines in text files.
For more information about line terminators, see the Windows vs. UNIX: Those pesky line terminators topic on the Network World website.
Script examples
$ file dotnetcoreinstall.sh //// Script created in Windows and uploaded to storage account
dotnetcoreinstall.sh: ASCII text, with CRLF line terminators
$ file dotnetcoreinstall.sh //// Script created in Linux and uploaded to storage account
dotnetcoreinstall.sh: ASCII text
To prevent the file format mismatch, do one of the following:
Create the script in a different Ubuntu environment, and upload the script to the storage explorer by using Storage Explorer for Linux.
If you do not have Storage Explorer in your Linux environment, get the script from the VM that was created in the previous step to your Windows environment by using the following Putty command. The Putty tool includes the executable pscp.exe.
After you send the file from Linux to Windows, upload the file to the storage account as is. To automate the process of converting files from Windows (DOS) to UNIX format, run the following command:
dos2unix dotnetcoreinstall.sh
To execute this command, you must first install the dos2unix package. To do this, run the following command:
sudo apt-get install dos2unix
Contact us for help
If you have questions or need help, create a support request, or ask Azure community support. You can also submit product feedback to Azure feedback community.
Third-party information disclaimer
The third-party products that this article discusses are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, about the performance or reliability of these products.
Third-party contact disclaimer
Microsoft provides third-party contact information to help you find additional information about this topic. This contact information may change without notice. Microsoft does not guarantee the accuracy of third-party contact information.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for