7

My Azure services target .Net 4.5.2 and run fine in dev. However, build produces the warning(s):

Warning The project 'SurfInfoWeb' targets .NET Framework 4.5.2. To make sure that the role starts, this version of the .NET Framework must be installed on the virtual machine for this role. You can use a startup task to install the required version, if it is not already installed as part of the Microsoft Azure guest OS.

I believe these (local) warnings are causing the publish to fail immediately (and these are the ONLY warnings in the error list).

According to MS, 4.5.2 is supposed to be available in January 2016 (I'm not sure exactly what date, but I thought I had read Jan 12 or Jan 16).

I can't suppress these warnings in the normal way because they don't have warning codes.

1) Is .Net 4.5.2 actually available on Azure

2) Is there a way to suppress warnings that don't have codes?

3) Something else I'm not thinking of?

I'm using SDK 2.8.1. And OSVersion="*".

Cœur
  • 37,241
  • 25
  • 195
  • 267
Bill O
  • 315
  • 4
  • 13

4 Answers4

8

Is .Net 4.5.2 actually available on Azure?

Yes. .NET 4.5.2 is available in the current osVersion * of osFamily 2, 3 and 4.

Is there a way to suppress warnings that don't have codes?

Cloud service projects upgraded to Azure SDK 2.9 no longer generate this warning. Projects using a prior version of the SDK (even if version 2.9 is installed) still generate this warning. To suppress this warning without upgrading the project to SDK 2.9 you can add the following snippet to your .ccproj file.

<ItemGroup> <WindowsAzureFrameworkMoniker Include=".NETFramework,Version=v4.5.2" /> </ItemGroup>

Oleg Sych
  • 6,548
  • 36
  • 34
2

Based on the comments provided here - https://azure.microsoft.com/en-in/documentation/articles/cloud-services-dotnet-install-dotnet/, there's no way to suppress this warning.

enter image description here

Is .Net 4.5.2 actually available on Azure?

As of today, yes. .Net 4.5.2 is available on Azure. In fact, we ported our solution from .Net 4.5 to .Net 4.5.2 just a few days ago.

In order to make use of .Net 4.5.2, you can't use "*" for osVersion. You would need to target a specific OS version. Please see the Guest OS/Target Framework version matrix here: https://azure.microsoft.com/en-in/documentation/articles/cloud-services-guestos-update-matrix/.

Our solution makes use of osFamily 4 and based on this matrix, we ended up using WA-GUEST-OS-4.26_201511-02 osVersion. Here's how our service configuration file looks like:

<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="ServiceName" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="WA-GUEST-OS-4.26_201511-02" schemaVersion="2015-04.2.6">
  <Role name="RoleName">
  </Role>
</ServiceConfiguration>
Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • I tried the suggested combination of OSFamily and OSVersion and got the same two warnings about needing to install 4.5.2. – Bill O Jan 19 '16 at 22:02
  • 1
    As mentioned in my response above, I don't think you will be able to suppress this warning at least as of today because not all osFamily/osVersion combination come with .Net 4.5.2 preinstalled. However if you use `osFamily = 4` & `osVersion = WA-GUEST-OS-4.26_201511-02`, your code would work just fine when deployed. With our product, we left `osVersion = *` and got the error when we ran the application. – Gaurav Mantri Jan 20 '16 at 03:06
  • Even though there's no built-in way to suppress it, you can [do what I did to suppress it](https://stackoverflow.com/a/52267513/398630). – BrainSlugs83 Sep 11 '18 at 01:32
0

I'm getting a similar version of this error, essentially, the new version of it:

Microsoft Azure Cloud Service projects only support roles that run on .NET Framework versions 4.0, 4.5 and 4.6. Please set the Target Framework property in the project settings for project 'MyWorkerRole' to .NET Framework 4.0, .NET Framework 4.5 or .NET Framework 4.6.

And

The project 'MyWorkerRole' targets .NET Framework 4.7.2. To make sure that the role starts, this version of the .NET Framework must be installed on the virtual machine for this role. You can use a startup task to install the required version, if it is not already installed as part of the Microsoft Azure guest OS. For more details, see https://go.microsoft.com/fwlink/?LinkId=309796.

Even after following the directions located at the link in the message (which were helpful in creating the installer scripts, etc.), the warning message did not go away. I tried all sorts of stuff including the framework moniker item groups, all kinds of properties, etc.

Ultimately, I ended up turning my build on Detailed output, figured out the .targets file this was coming from and inspected it. -- I found that there is just no built-in way to suppress it.

HOWEVER, there is a hack you can do -- I basically copied that block from the .targets file into my .ccproj file, and removed the part about the warning. Basically I added the following to the end of my .ccproj file, and BADAO!, just like that NO MORE WARNINGS!:

<Target Name="ValidateRoleTargetFramework"
        Outputs="%(RoleReference.Identity)"
        Condition="'@(RoleReference)' != ''">

  <PropertyGroup>
    <_RoleTargetFramework>%(RoleReference.RoleTargetFramework)</_RoleTargetFramework>
    <_IsValidRoleTargetFramework>False</_IsValidRoleTargetFramework>
    <_IsValidRoleTargetFramework
      Condition="$(_RoleTargetFramework.StartsWith('v4.0')) Or $(_RoleTargetFramework.StartsWith('v4.5')) Or $(_RoleTargetFramework.StartsWith('v4.6'))">True</_IsValidRoleTargetFramework>
  </PropertyGroup>

</Target>

(Obviously, you should put that INSIDE your <Project /> tag, of course.)

BrainSlugs83
  • 6,214
  • 7
  • 50
  • 56
-1

You should to install .net 4.5.2 on webrole virtual machine.

Download the the web installer for the .NET framework you want to install .NET 4.5.2 Web Installer

For a Web Role

  1. In Solution Explorer, under In Roles in the cloud service project right click on your role and select Add>New Folder.
  2. Create a folder named bin Right click on the bin folder and select Add>Existing Item. Select the .NET installer and add it to the bin folder.
  3. Define startup task for your role ServiceDefinition.csdef <LocalResources> <LocalStorage name="NETFXInstall" sizeInMB="1024" cleanOnRoleRecycle="false" /> </LocalResources> <Startup> <Task commandLine="install.cmd" executionContext="elevated" taskType="simple"> <Environment> <Variable name="PathToNETFXInstall"> <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/LocalResources/LocalResource[@name='NETFXInstall']/@path" /> </Variable> </Environment> </Task> </Startup>
  4. Create a file install.cmd and add it to role by right click on the role and selecting Add>Existing Item.

install.cmd

```

REM Set the value of netfx to install appropriate .NET Framework. 
REM ***** To install .NET 4.5.2 set the variable netfx to "NDP452" *****
REM ***** To install .NET 4.6 set the variable netfx to "NDP46" *****
REM ***** To install .NET 4.6.1 set the variable netfx to "NDP461" *****
set netfx="NDP46"

REM ***** Needed to correctly install .NET 4.6.1, otherwise you may see an out of disk space error *****
set TMP=%PathToNETFXInstall%
set TEMP=%PathToNETFXInstall%

REM ***** Setup .NET filenames and registry keys *****
if %netfx%=="NDP461" goto NDP461
if %netfx%=="NDP46" goto NDP46
    set netfxinstallfile="NDP452-KB2901954-Web.exe"
    set netfxregkey="0x5cbf5"
    goto logtimestamp

:NDP46
set netfxinstallfile="NDP46-KB3045560-Web.exe"
set netfxregkey="0x60051"
goto logtimestamp

:NDP461
set netfxinstallfile="NDP461-KB3102438-Web.exe"
set netfxregkey="0x6041f"

:logtimestamp
REM ***** Setup LogFile with timestamp *****
set timehour=%time:~0,2%
set timestamp=%date:~-4,4%%date:~-10,2%%date:~-7,2%-%timehour: =0%%time:~3,2%
md "%PathToNETFXInstall%\log"
set startuptasklog="%PathToNETFXInstall%log\startuptasklog-%timestamp%.txt"
set netfxinstallerlog="%PathToNETFXInstall%log\NetFXInstallerLog-%timestamp%"

echo Logfile generated at: %startuptasklog% >> %startuptasklog%
echo TMP set to: %TMP% >> %startuptasklog%
echo TEMP set to: %TEMP% >> %startuptasklog%

REM ***** Check if .NET is installed *****
echo Checking if .NET (%netfx%) is installed >> %startuptasklog%
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" /v Release | Find %netfxregkey%
if %ERRORLEVEL%== 0 goto end

REM ***** Installing .NET *****
echo Installing .NET: start /wait %~dp0%netfxinstallfile% /q /serialdownload /log %netfxinstallerlog% >> %startuptasklog%
start /wait %~dp0%netfxinstallfile% /q /serialdownload /log %netfxinstallerlog% >> %startuptasklog% 2>>&1

:end
echo install.cmd completed: %date:~-4,4%%date:~-10,2%%date:~-7,2%-%timehour: =0%%time:~3,2% >> %startuptasklog%

```

You can get the full detailed procedures here:

Install .NET on a Cloud Service Role

I think you should implement this workaround until Azure full support .net 4.5.2 may be is not yet supported in your region.Try creating a new cloud instance in EastUS to test if net fx 4.5.2 is already supported.

JuanK
  • 2,056
  • 19
  • 32
  • Now that .Net 4.5.2 is supported on certain combinations of osFamily/osVersions, you don't really need to do all of these steps. – Gaurav Mantri Jan 19 '16 at 18:34
  • I understand I can install it explicitly, but since MS has announced that it is going to do (or already has done) a forced in-place upgrade to 4.5.2, I thought it would be available as a target at the time of that upgrade action. I also understand that it wasn't available as a target until now, but that it could be explicitly requested through OSVersion, without doing the install. Those two facts combined make me think I'm doing something else wrong. (Thanks for the formatting; looks much better) – Bill O Jan 19 '16 at 18:38
  • You aren't doing nothing wrong. The current OS family/version you're using doesn't support .net 4.5.2. If you aren't able to upgrade host version the required steps to support tis framework is installing it in the server. – JuanK Jan 19 '16 at 19:00
  • @JuanK Why do you say that? .Net 4.5.2 is now supported on both OS family 3 & 4. – Gaurav Mantri Jan 19 '16 at 19:41
  • @GauravMantri I don't know what Host OS version Bill has currently available. If he can migrate the OS version in all instances without any problem obviously the solution is just migrate them. – JuanK Jan 19 '16 at 20:05
  • I also tried osVersion="WA-GUEST-OS-4.26_201511-02". Same result. – Bill O Jan 19 '16 at 21:55
  • Added to the post: I think you should implement the workaround above until Azure full support .net 4.5.2 may be is not yet supported in your region.Try creating a new cloud instance in EastUS to test if net fx 4.5.2 is already supported – JuanK Jan 19 '16 at 22:52
  • Even if you do this, it doesn't make the warning go away. :( – BrainSlugs83 Sep 04 '18 at 14:34