Why doesn't mywebsite.dll.config get included in my cspkg? - azure

I have an azure web role with Azure SDK 2.3.
My web site project website has web.config, which gets copied to bin/debug/website.dll.config properly during build.
But Azure SDK totally fails to include this DLL in the cspkg which causes my role OnStart to fail, since it depends on binding redirects in the web.config to load the correct version of the Azure runtime assemblies. Anyone got any bright idea why cspack isn't including this file and what to do about it?

web.config files are never copied as projectNAme.dll.config!
Only application.config files are copied this way. And yes, for Web Roles nothing beside the regular web.config are automatically copied.
You have to name your configuration file following the name of your main application assembly (i.e. website.dll.config) and then explicitly mark it with Copy Always in the properties panel, section Copy to output folder. Thus the file will be included into the web role package.

Related

Azure App Service keeping old files at /home/site/wwwroot/

I'm deploying nodejs application to Azure App Service with visual studio code extension (Deploy to web app). However when I inspect the files section, I found some old file/ files from previous deployment are still exist at /home/site/wwwroot/ folder.
For example first deployment have A.js, and second deployment I renamed it to B.js, /home/site/wwwroot/ will endup with A.js and B.js.
How can I resolved this issue? Any suggestion will be appreciated, thank you!
on publish page click on show all settings.
Make sure Remove additional files at destination.
Before check Remove additional files at destination. showing old file on wwwroot folder.
After check Remove additional files at destination. showing old file on wwwroot folder.

Error deploying to azure app service - "specified path, file name, or both are too long. The fully qualified file name must be < 260 characters"

I was trying to deploy my web app to a web app service I created in Azure services portal. I was doing it through Visual Studio Code with the help of Azure extensions (idk if that's important to mention or no). I got this error:
"The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters"
Unfortunately, I can not change file names or move the project to a different folder. What can I do to fix this issue? Thanks in advance :)
Please check if the below steps help to fix the issue:
If it is Node JS Web App, delete the folder called node_modules within the project folder. Reload the solution > Rebuild and publish to the Azure. In the Azure Portal > Web App > Console - run the command npm install which adds the dependencies within that project with the folder called node_modules.
If possible, try to move your projects/solutions to the root directory or to the short directory path.
According to this similar issue reported in the GitHub Repo-Azure Web App, you can include a setting in publish profile file like:
<PublishTempFolderName>i2</PublishTempFolderName>
Check that reference when using the above setting, some global settings need to be applied given on the GitHub Repo
(OR) Enable the policy state of Enable NTFS long paths in the Local Group Policy Editor and check once.

Can I disable shadow copy in an Azure function?

We are working on a new feature that uses third-party plugins that are stored in a directory named 'Plugins'. One particular plugin expects certain files such as the license file to be in the same directory as the plugin assembly (DLL) based on the assembly's Location value. However, due to shadow copy the license file is in the folder where it was originally deployed and the assembly Location value is the 'Temporary ASP.NET Files' subfolder after shadow copy. Is there any way to disable shadow copy to work around this issue?
I suggested to the plugin provider to use CodeBase rather than Location. They are considering it, but I have to complete this feature now so I can't wait for that code change.
My current desire is to disable shadow copy so the Location property value of the assembly is the location where all the plugin files are initially deployed to.
Cause Azure Function doesn't support web.config, have to find other ways to implement it.
In github there is one way to solve it, and in this comment it says no shadowcopy in v2, maybe you could have a try. Add this directive in your Web Deploy pubxml for your publish profile:
<EnableMsDeployAppOffline>True</EnableMsDeployAppOffline>

Include referenced assembly's configuration in cspkg

I have an executable that I want to be deployed together with my Azure web role. The executable has a configuration file that needs to be included as well.
I tried adding a reference to the executable's project in my web role project, which made the exe file appear in the bin folder of the cspkg, but not the configuration file.
How can I get the configuration file to be included as well?
It seems wrong to include it directly as a content file in the web role project because this file is a build artifact (app.config gets renamed to .config.exe during build).
Thanks!
In an early SDK they added the concept of Role Content folders, or folders you could point to in the service definition file and say anything in this folder, add it to the package and deploy it with the role. If you look at the schema for the Service Definition you'll see these listed on the both the web and worker roles schemas. You can manually add this and point to any location on the local system and anything in that directory will be picked up and included.
<WebRole name="SimpleWeb" vmsize="Small">
...
<Contents>
<Content destination="ConsoleApp">
<SourceDirectory path="c:\src\SimpleWebContent\ConsoleApp\BuildOutput" />
</Content>
</Contents>
</WebRole>
For example, you could point to the output directory of the build for your executable so that anything that is generated by your build for that executable would be included. You can set the destination directory in relation to the app root, but the tricky part is the source directory. Note in my example above the full path is provided. The documentation says that you can use a relative path, but I tried many combinations and the behavior seemed very quirky. The complete path does work.
The VS SDK tools didn't expose this until SDK 1.7 and it's still not very good. Phil Hoff did a blog post on it called "Add Files to your Windows Azure Package using Role Content Folders". Note that when you use this method of adding the files you won't see the content elements appear in your service definition. They get auto injected at package time. If you are doing this as part of a build process that may not happen since VS tooling is doing the injection, but to be fair I didn't try calling cspack directly to see if having the content elements included in the service definition file actually packaged those or not. Also, I found that just adding a new folder and just having files under that folder didn't seem to work. I had to actually add the files by name there, which seemed wrong. I did hack the .ccproj file to use a wildcard on the folder include, which did work, but also seemed like a hack to me.

Hosting an ISAPI DLL and supporting files in Azure

I am trying to find out how to host an ISAPI DLL in Azure. In addition to the DLL, I'll need to deploy supporting files in subdirectories (javascript & css files). And two of these subdirectories can have their contents changed by requests handled by the DLL, so I need to ensure that the account executing the extension has write permission for these.
It would seem that the key to all of this is using a startup task to call appcmd to script all the IIS changes somehow, and I think I need to do the following:-
Deploy my ISAPI DLL and supporting files with my ASP.NET website
Create a startup task which will call a batch file utilizing appcmd.exe to do the following:-
Create a dedicated app pool with its managed pipeline mode set to Classic, and using a known user account
Create an IIS application pointing to the directory where my ISAPI dll resides
Ensure the application is configured to allow unknown ISAPI extensions
Alter the permissions of the required subdirectories so the user account associated with the app pool has write access
I've only just started exploring Azure, so my experience with it is very thin on the ground. Is what I'm hoping to achieve actually achievable? And if so, am I on the right track with regards to the steps required? They mimic what I need to do if I'm setting up this ISAPI DLL in the traditional IIS environment I'm used to dealing with, but please let me know if the rules are different with Azure.
Looks like a good sequence, however, the startup tasks actually run before IIS is completely configured. The 'OnStart' event in the RoleEntryPoint is called after IIS is set up, so it's probably easier to use the IIS application that Azure creates for you, and reconfigure it to include your ISAPI stuff.
Well the only thing bothering me here is that you're modifying data on the 'deployment drive' (E: for that matter). You shouldn't be doing this.
Instead, think of an other solution. You could create a LocalResource holding your javascript and CSS files. Then, when your role starts (Richard has a valid point about startup tasks), use ServerManager class to do the following:
Register the ISAPI dll
Add 2 virtual directories under the website created by Azure and point them to the LocalResource.
Modify the code of your ISAPI dll to modify JS/CSS files in the LocalResource
When developing in Web/WorkerRoles, you need to keep in mind that you should only manipulate files in a LocalResource.

Resources