Update azure.html

This commit is contained in:
Oleg Zhurakousky
2019-07-12 18:59:43 +02:00
committed by GitHub
parent 9a41a078b9
commit 17325cea68

View File

@@ -90,6 +90,7 @@ $(addBlockSwitches);
<ul class="sectlevel2">
<li><a href="#_accessing_azure_executioncontext">Accessing Azure ExecutionContext</a></li>
<li><a href="#_notes_on_jar_layout">Notes on JAR Layout</a></li>
<li><a href="#_build_file_setup">Build file setup</a></li>
<li><a href="#_build">Build</a></li>
<li><a href="#_running_the_sample">Running the sample</a></li>
</ul>
@@ -102,7 +103,7 @@ $(addBlockSwitches);
<p><strong>3.0.0.M1</strong></p>
</div>
<div id="index-link" class="paragraph">
<p><a href="https://cloud.spring.io/spring-cloud-function/home.html" class="bare">https://cloud.spring.io/spring-cloud-function/home.html</a></p>
<p><a href="https://cloud.spring.io/spring-cloud-static/spring-cloud-function/3.0.0.M1/home.html" class="bare">https://cloud.spring.io/spring-cloud-static/spring-cloud-function/3.0.0.M1/home.html</a></p>
</div>
<div class="paragraph">
<p>The <a href="https://azure.microsoft.com">Azure</a> adapter bootstraps a Spring Cloud Function context and channels function calls from the Azure framework into the user functions, using Spring Boot configuration where necessary. Azure Functions has quite a unique, but invasive programming model, involving annotations in user code that are specific to the platform. The easiest way to use it with Spring Cloud is to extend a base class and write a method in it with the <code>@FunctionName</code> annotation which delegates to a base class method.</p>
@@ -167,7 +168,84 @@ public Function&lt;Foo, Bar&gt; uppercase(ExecutionContext targetContext) {
<div class="sect2">
<h3 id="_notes_on_jar_layout"><a class="link" href="#_notes_on_jar_layout">Notes on JAR Layout</a></h3>
<div class="paragraph">
<p>You don&#8217;t need the Spring Cloud Function Web at runtime in Azure, so you can exclude this before you create the JAR you deploy to Azure, but it won&#8217;t be used if you include it so it doesn&#8217;t hurt to leave it in. A function application on Azure is an archive generated by the Maven plugin. The function lives in the JAR file generated by this project. The sample creates it as an executable jar, using the thin layout, so that Azure can find the handler classes. If you prefer you can just use a regular flat JAR file. The dependencies should <strong>not</strong> be included.</p>
<p>You don&#8217;t need the Spring Cloud Function Web at runtime in Azure, so you can exclude this
before you create the JAR you deploy to Azure, but it won&#8217;t be used if you include it, so
it doesn&#8217;t hurt to leave it in. A function application on Azure is an archive generated by
the Maven plugin. The function lives in the JAR file generated by this project.
The sample creates it as an executable jar, using the thin layout, so that Azure can find
the handler classes. If you prefer you can just use a regular flat JAR file.
The dependencies should <strong>not</strong> be included.</p>
</div>
</div>
<div class="sect1">
<h2 id="_build_file_setup"><a class="link" href="#_build_file_setup">Build file setup</a></h2>
<div class="sectionbody">
<div class="paragraph">
<p>In order to run Spring Cloud Function applications on Microsoft Azure, you can leverage the Maven
plugin offered by the cloud platform provider.</p>
</div>
<div class="paragraph">
<p>In order to use the adapter plugin for Maven, add the plugin dependency to your <code>pom.xml</code>
file:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-xml hljs" data-lang="xml">&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
&lt;artifactId&gt;spring-cloud-function-adapter-azure&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then, configure the plugin. You will need to provide Azure-specific configuration for your
application, specifying the <code>resourceGroup</code>, <code>appName</code> and other optional properties, and
add the <code>package</code> goal execution so that the <code>function.json</code> file required by Azure is
generated for you. Full plugin documentation can be found in the <a href="https://github.com/microsoft/azure-maven-plugins">plugin repository</a>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-xml hljs" data-lang="xml">&lt;plugin&gt;
&lt;groupId&gt;com.microsoft.azure&lt;/groupId&gt;
&lt;artifactId&gt;azure-functions-maven-plugin&lt;/artifactId&gt;
&lt;configuration&gt;
&lt;resourceGroup&gt;${functionResourceGroup}&lt;/resourceGroup&gt;
&lt;appName&gt;${functionAppName}&lt;/appName&gt;
&lt;/configuration&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;id&gt;package-functions&lt;/id&gt;
&lt;goals&gt;
&lt;goal&gt;package&lt;/goal&gt;
&lt;/goals&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>You will also have to ensure that the files to be scanned by the plugin can be found in the
Azure functions staging directory (see the <a href="https://github.com/microsoft/azure-maven-plugins">plugin repository</a>
for more details on the staging directory and it&#8217;s default location).</p>
</div>
<div class="paragraph">
<p>You can find the entire sample <code>pom.xml</code> file for deploying Spring Cloud Function
applications to Microsoft Azure with Maven <a href="https://github.com/spring-cloud/spring-cloud-function/blob/2.1.x/spring-cloud-function-samples/function-sample-azure/pom.xml">here</a>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
As of yet, only Maven plugin is available. Gradle plugin has not been created by
the cloud platform provider.
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">