Getting error while deploying the java spring boot application in the azure function

I have created an application using java spring boot. I want to deploy it in the azure function app and im deploying it in the azure function app via vs code by using the below commands

  • ./mvnw clean package
  • ./mvnw azure-functions:deploy

when i run the second command im getting “device code consumer is not configured.” error and the build is failing.

Can any one answer my question please.

i tried both the commands by configuring the pom.xml file with the required azure function app details and deployed it in the function app.

Recognized by Microsoft Azure Collective

New contributor

Jatin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

To resolve this issue, login to Azure by running the below commands in Terminal:

1. az login
2. az account set --subscription <your_subscription_id>

You can also specify the function to use Azure CLI credential explicitly with below configuration under azure-functions-maven-plugin in pom.xml:

<configuration>
     <auth><type>azure_cli</type></auth>
</configuration>

Run the function locally using the commands:

mvn clean install
mvn azure-functions:run

pom.xml:

    <name>Azure Java Functions</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>17</java.version>
        <azure.functions.maven.plugin.version>1.36.0</azure.functions.maven.plugin.version>
        <azure.functions.java.library.version>3.1.0</azure.functions.java.library.version>
        <functionAppName>javafn-1727176226852</functionAppName>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.microsoft.azure.functions</groupId>
            <artifactId>azure-functions-java-library</artifactId>
            <version>${azure.functions.java.library.version}</version>
        </dependency>
        <!-- Test -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.4.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>2.23.4</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.microsoft.azure</groupId>
                <artifactId>azure-functions-maven-plugin</artifactId>
                <version>${azure.functions.maven.plugin.version}</version>
                <configuration>
                    <appName>${functionAppName}</appName>
                    <resourceGroup>java-functions-group</resourceGroup>
                    <region>westus</region>
                    <appServicePlanName>java-functions-app-service-plan</appServicePlanName>
                    <runtime>
                        <os>windows</os>
                        <javaVersion>17</javaVersion>
                    </runtime>
                    <appSettings>
                        <property>
                            <name>FUNCTIONS_EXTENSION_VERSION</name>
                            <value>~4</value>
                        </property>
                    </appSettings>
                </configuration>
                <executions>
                    <execution>
                        <id>package-functions</id>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!--Remove obj folder generated by .NET SDK in maven clean-->
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>obj</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Deploy the function to Azure function app using the command mvn azure-functions:deploy:

C:Usersunamejavafn> mvn azure-functions:deploy
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------< com.function:javafn >-------------------------
[INFO] Building Azure Java Functions 1.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- azure-functions:1.36.0:deploy (default-cli) @ javafn ---
[INFO] Auth type: AZURE_CLI
[INFO] Username: uname
[INFO] Subscription: your_subscription(d93XXX-8856-a7f4589e52bc)
[INFO] Start creating Storage Account(d6ac9aXXX46f2b6c8)...
[INFO] Storage Account(d6ac9ab1XXb46f2b6c8) is successfully created.
[WARNING] Skip validation as schema appservice/CreateAppServicePlan was not registered
[INFO] Start creating App Service plan (java-functions-app-service-plan)...
[INFO] App Service plan (java-functions-app-service-plan) is successfully created
[INFO] Set function worker runtime to java.
[INFO] Start creating Function App(javafn-1727176226852)...
[INFO] Function App(javafn-1727176226852) is successfully created
[INFO] Starting deployment...
[INFO] Trying to deploy artifact to javafn-1727176226852...
[INFO] Successfully deployed the artifact to https://javafn-1727176226852.azurewebsites.net
[INFO] Deployment succeed
[INFO] Syncing triggers and fetching function information
[INFO] Querying triggers...
[INFO] HTTP Trigger Urls:
         HttpExample : https://javafn-1727176226852.azurewebsites.net/api/httpexample

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:54 min
[INFO] Finished at: 2024-09-24T17:10:53+05:30
[INFO] ------------------------------------------------------------------------

Deployed the function to Azure successfully:

Portal:

Recognized by Microsoft Azure Collective

Seems the problem is with the authentication to Azure while deploying the code. Before you deploy make sure you login to the Azure subscription using the az cli

az login

you can also refer my articles, it has tested sample code:

https://www.baeldung.com/java-azure-functions

https://www.baeldung.com/spring-cloud-function-microsoft-azure

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật