referring to this question i've tried to write that example in my WebRole.OnStart and I keep getting the following
Details: Role has encountered an error and has stopped. Unhandled Exception: System.Net.WebException, Details: Exception: The underlying connection was closed: An unexpected error occurred on a send.
at System.Net.HttpWebRequest.GetResponse()
at
and as the publish log specifies the IISConfigurator startup task didn't run yet
is there any other solution
i'm using
cloud-service classic
azure API 2.8.2
Visual Studio 2015 Update 1
You can execute a script when the host VM starts by including the script in your project and adding a startup task to the ServiceDefinition.csdef. In the example below we run Startup.cmd. We use this to disable idleTimeout for our site by calling appcmd.exe from within the script.
Below is the Startup node you add to WebRole as a sibling to Sites in ServiceDefinition.csdef. Also included is how to inject runtime variables that can be accessed via RoleEntryPoint, great article on RoleEntryPoint here.
<Startup>
<Task commandLine="Startup.cmd" executionContext="elevated" taskType="simple">
<Environment>
<Variable name="isEmulated">
<RoleInstanceValue xpath="/RoleEnvironment/Deployment/#emulated" />
</Variable>
<Variable name="instanceId">
<RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/#id" />
</Variable>
<Environment>
</Task>
Related
I`m trying to deploy New Azure Service (using SDK 2.9) and encounter the following error:
The file provided is not a valid service package.
Invalid application runtime - a runtime component is missing:/base/x64/WaHostBootstrapper.exe.config.
Screenshot of the error
What did I try:
Tried to package the service and saw "base/x64/WaHostBootstrapper.exe.config" exists and not missing. Screenshot of the Package Folder
Tried to deploy other service from different workload (also SDK 2.9) it works.
Tried to compare the content of WaHostBootstrapper.exe.config between the to mentioned sevices and it was identical
Attaching the contents of the file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
<runtime>
<NetFx40_LegacySecurityPolicy enabled="false" />
</runtime>
</configuration>
Any ideas what else can I check or try to do?
Thanks a lot for you help
When I try to publish an azure app I get this error.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(4283,5): Error : The 'ibasis_Data_Transfer.mytestdbEntities-Web.config Connection String' argument cannot be null or empty.
My App.Config has a connection string. e.g.
<add name="mytestdbEntities" connectionString="metadata=res://*/mytestappModel.csdl|res://*/mytestappModel.ssdl|res://*/mytestappModel.msl;provider=System.Data.SqlClient;provider connection string="data source=tcp:srv-mytestapp-home.database.windows.net,1433;initial catalog=mytestdb;persist security info=True;user id=blabla;password=blabla;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Don't know where to start looking for solution as error not mentioned on web anywhere in relation to azure.
ibasis - Web Deploy.pubxml
<?xml version="1.0" encoding="utf-8" ?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>http://ibasis.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
<MSDeployServiceURL>ibasis.scm.azurewebsites.net:443</MSDeployServiceURL>
<DeployIisAppPath>ibasis</DeployIisAppPath>
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<UserName>$ibasis</UserName>
<_SavePWD>True</_SavePWD>
<_DestinationType>AzureWebSite</_DestinationType>
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="ibasis_Data_Transfer.ibasisLiveEntities" Order="1" Enabled="False">
<Destination Path="" />
<Object Type="DbCodeFirst">
<Source Path="DBContext" DbContext="ibasis_Data_Transfer.ibasisLiveEntities, ibasis-Data-Transfer" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
</PropertyGroup>
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)ibasis_Data_Transfer.ibasisLiveEntities-Web.config Connection String" />
</ItemGroup>
<ItemGroup>
<_ConnectionStringsToInsert Include="ibasis_Data_Transfer.ibasisLiveEntities" />
</ItemGroup>
</Project>
Update: As far as i can tell the VS publishing of simple Apps to Azure with 'database first' type entity(edmx) files is not possible.
The auto generated ....Web Deploy.pubxml gets filled with incompatible junk like and "DeployParameterPrefix" which can't be removed and break the build.
I only wanted to call simple Stored Procedure e.g.
myappLiveEntities db = new myappLiveEntities();
db.DoSomeDatabaseWork();
Will do it "old school" method.
I ran into this with a webjob I had been deploying successfully. I wound up deleting the pubxml file under the webjob project PublishProfiles folder and redoing the publish As Azure WebJob.
This issue popped up again when I upgraded to this specific nuget package:
"Microsoft.WindowsAzure.ConfigurationManager" version="3.2.3"
It may be an issue with publishing the webjob before publishing the updated web app or editing the WebApp publish settings ...
Edit: I've since switched to including the web job to the web app publish settings. You can do this by right clicking the project and choosing Add -> Existing Project as Azure Web Job. I no longer publish the WebJob separately.
I believe you need to add a ParameterValue under the MSDeployParameterValue list item. For example,
<ItemGroup>
<MSDeployParameterValue Include="Parameter Name">
<ParameterValue>Parameter Value</ParameterValue>
</MSDeployParameterValue>
</ItemGroup>
We are using VSO and Azure Cloud Services (web roles).
Previously, we have used the following build.proj file for our VSO build definitions:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutDir>$(MSBuildThisFileDirectory)bin</OutDir>
<Configuration>Release</Configuration>
<ProjectProperties>OutDir=$(OutDir);Configuration=$(Configuration);</ProjectProperties>
</PropertyGroup>
<ItemGroup>
<Solution Include="$(MSBuildThisFileDirectory)*.sln" />
</ItemGroup>
<Target Name="RestorePackages">
<Exec Command=""$(MSBuildThisFileDirectory).nuget\NuGet.exe" restore "%(Solution.Identity)"" />
</Target>
<Target Name="Clean">
<MSBuild Targets="Clean" Projects="#(Solution)" Properties="$(ProjectProperties)" />
</Target>
<Target Name="Build" DependsOnTargets="RestorePackages">
<MSBuild Targets="Build" Projects="#(Solution)" Properties="$(ProjectProperties)" />
</Target>
<Target Name="Rebuild" DependsOnTargets="RestorePackages">
<MSBuild Targets="Rebuild" Projects="#(Solution)" Properties="$(ProjectProperties)" />
</Target>
</Project>
The reason for this is to execute NuGet restore before MSBuild began running. This is a suggested approach by NuGet.
Now that we are trying to set up continuous integration with our Azure cloud services, as instructed in this MSDN article.
This means that we must now use the TfvcContinuousDeploymentTemplate.12.xml build process template.
But when setting the template to build the build.proj file, the following build error occurs:
Exception Message: Deploying to Azure Cloud Service requires a Visual Studio Solution (.sln) that contains either a ccproj or a lsxproj. (type DeploymentException)
Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
When using the .sln, all works fine. But we obviously also need NuGet restore to occur before the build.
What is a good solution to have both continuous integration AND NuGet restore working?
I have just learnt that this is redundant. There is no reason to manually execute NuGet restore as this is already built into VSO/TFS.
Read more here.
I have a simple file in the root of my Web project (which is tied to a Web worker role). The file is named Startup.cmd. This file contains the following line: dir > directory.txt. It executes properly when I run it from the command line and outputs a list of the directory contents to file named directory.txt as you would expect. Similarly, the line ECHO Write this line to file > output.txt does not appear to work either.
Inside ServiceDefinition.csdef for my Azure Cloud Service project, I have the following lines:
<WebRole name="Website" vmsize="Small">
<Startup>
<Task commandLine="Startup.cmd" executionContext="elevated" taskType="simple"></Task>
</Startup>
....
</WebRole>
I believe it is finding the file, because I have tried changing the path and it will throw a build error that it cannot find it. The issue is that when I check my /bin/ directory after debugging to the Azure Debugging Environment, I see Startup.cmd (I have it set to Copy always) but I do not see directory.txt. I'm not sure of another way to confirm that it executed properly.
I found the following MSDN article useful: http://msdn.microsoft.com/en-us/library/hh180155.aspx.
As a result, I made some changes to my Startup.cmd file. I changed the command to:
ECHO The current version is %MyVersionNumber% >> "%TEMP%\StartupLog.txt" 2>&1
EXIT /B 0
However, this did not appear to put the output in my temporary directory for my system: C:\Users\username\AppData\Local\Temp. I'm going to presume this is because the Azure Compute Emulator uses a different temp directory I am unaware of.
I changed my Startup.cmd to:
ECHO The current version is %MyVersionNumber% >> "c:\temp\StartupLog.txt" 2>&1
EXIT /B 0
And updated my configuration to:
<WebRole name="Website" vmsize="Small">
<Startup>
<Task commandLine="Startup.cmd" executionContext="elevated" taskType="simple">
<Environment>
<Variable name="MyVersionNumber" value="1.0.0.0" />
<Variable name="ComputeEmulatorRunning">
<RoleInstanceValue xpath="/RoleEnvironment/Deployment/#emulated" />
</Variable>
</Environment>
</Task>
</Startup>
...
</WebRole>
And this did appear to write the file to C:\temp\ upon starting the debugger.
I have an xml file that I ma tryin to read from
string xmlTemplatePath = Path.Combine(Environment.GetEnvironmentVariable("RoleRoot") + #"\", #"approot\myxml.xml");
Using XDocument doc = XDocument.Load(xmlTemplatePath), however I get an access denied exception both on the cloud and development environment. Any ideas why a read is denied?
I know, old thread... but the answer could be useful to someone nevertheless.
It appears that an azure worker process runs under a custom user (shows up as a GUID in taskmgr). This user account appears to be quite restricted and has no read-access to the filesystem (even inside the approot directory).
My solution was to create a startup script for the azure role (see msdn article) which uses icacls to add permissions to access the files. In this case, I created a file called startup\Install.cmd in my project, containing the following:
#echo off
if "%EMULATED%"=="true" goto :EOF
echo Allowing access to files
cd directory_where_files_exist
icacls *.* /grant Everyone:F
In my ServiceDefinition.csdef file, I instruct the Azure deployment system to run this startup script during deployment by putting this inside the role definition (e.g. <WorkerRole>):
<Startup>
<Task executionContext="elevated" commandLine="startup\Install.cmd">
<Environment>
<Variable name="EMULATED">
<RoleInstanceValue xpath="/RoleEnvironment/Deployment/#emulated" />
</Variable>
</Environment>
</Task>
</Startup>
The variable "EMULATED" is set when the emulator is running - note that in the startup/Install.cmd file above, I skip doing the permission change if running in the emulator.
Looks fine to me. I even grabbed your code and dropped it into a worker role, calling it from OnStart(), after creating myxml.xml in my project root, just to make sure I wasn't missing something obvious.
Check myxml.xml properties: "Build Action" should be "Content" and "Copy to Output Directory" should be "Copy always" or "Copy if newer". If that doesn't fix it, check permissions on that file.