0

I have an OData Web Api service which I am deploying as a cloudservice. I also have an website which is created with some grunt tasks which create a dist folder with all the compiled stuff in it.

What I now want to do is add this folder to the Cloudservice project. I already tried what is suggested here, but this will only copy the folder into the approots of the cloudservice, not in sitesroot/0/. So the website is not accessible when deployed.

How can I add an folder while building to my Cloud Service so it is an folder that is accessible from IIS? For example, if I want my dist folder to be accessible as: http://mysite.cloudapp.net/dist/ or http://mysite.cloudapp.net/client/

I could add it to the WebRole project with the OData service, but this folder is a "moving target", there will be files added and removed, so hard adding it to the WebRole project will be most inconvenient.

Community
  • 1
  • 1
Malyngo
  • 863
  • 7
  • 18

2 Answers2

0

Couldn't you have the code which deposits files into this folder, create it if it doesn't exist?

Other than that, jut adding it to your WebRole OData service project as you suggested.

0

The solution for this turned out pretty simple: Analogue to the solution for the additional content folders here: Adding additional content folders to Azure package

but instead of adding the folder in the servicedefinition.csdef to the contents section, just add it as a virtual directory.

So just like in the solution for the content folder, add a task in the ccproj file:

<UsingTask
    TaskName="SetEnvironmentVariableTask"
    TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll">
    <ParameterGroup>
      <Name ParameterType="System.String" Required="true" />
      <Value ParameterType="System.String" Required="true" />
    </ParameterGroup>

    <Task>
      <Using Namespace="System" />
      <Code Type="Fragment" Language="cs">
        <![CDATA[
          Environment.SetEnvironmentVariable(Name, Value);
        ]]>
      </Code>
    </Task>
  </UsingTask>
  <Target Name="BeforeBuild" Condition=" '$(FrontendDir)' == '' ">
    <Message Text="Setting Project Dir" Importance="high" />
    <SetEnvironmentVariableTask Name="FrontendDir" Value="$(ProjectDir)\..\Template.FrontEnd\dist" />
  </Target>

But then, instead of adding it as content, add the folder as a virtual directory:

        <Site name="Web">
            <VirtualDirectory name="Client" physicalDirectory="%FrontendDir%"></VirtualDirectory>
            <Bindings>
                <Binding name="Endpoint1" endpointName="Endpoint1" />
                <Binding name="HttpsIn" endpointName="HttpsIn" />
            </Bindings>
        </Site>
Community
  • 1
  • 1
Malyngo
  • 863
  • 7
  • 18