question

khattabkhairdeen avatar image
khattabkhairdeen asked

Azure Functions in Unity

I have a couple of questions: can i use azure functions to read and write player data, acting as the actual server? and also, do i need an azure account if im only using these functions in unity? if i can use this as the server, how do i enable the server api on it since its an entirely new project. the docs for it say to use an azure template in vs so its not even attatched to the unity project.. i assume i have to just paste the http result in and the function name, wondering if i have to first register that to the azure website or if i can just do it without registration, just via playfab.

apisPlayer DataCustom Game Servers
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

>> I have a couple of questions: can i use azure functions to read and write player data, acting as the actual server?

Azure Functions can implement your requirement. You can read and write the player read-only, internal data on Azure Functions using PlayFab server API, then handle them in your own server-side logic and return the function results as responses.

But you may need to note, Azure Functions is a serverless function that can be used to handle the light-level server-side logic. For example, executing serverless functions is an event-driven computing experience, it is different from actual servers that allow you to deploy the services and run them on the ongoing basis. Azure functions cannot completely replace servers.

Please check the Azure Functions documentation series - Azure Functions Overview | Microsoft Docs to learn more about Azure Functions and check our documentation - PlayFab CloudScript using Azure Functions Quickstart Guide - PlayFab | Microsoft Docs to learn about how to integrate and use it with PlayFab.

>> and also, do i need an azure account if im only using these functions in unity?

To use Azure functions, you need to have a separate Azure account and Azure Subscription. And the usage of Azure Functions will be charged separately. You can navigate to specifical Azure Functions Pricing Page - Pricing – Functions | Microsoft Azure for more information about its price.

Besides, after you deploy your Azure Functions, clients can access them using REST API. Such backend services are cross-platform. It does not depend on how many platforms you use as clients.

>> if i can use this as the server, how do i enable the server api on it since its an entirely new project. the docs for it say to use an azure template in vs so its not even attatched to the unity project..

The Azure Functions project is a separate project that supports be built using C# program language. It does not support be attached to Unity and does not need to use any Unity SDK.

For your case, please follow our tutorials to import C# PlayFab All SDK to your C# Azure Functions project, then do the continued steps. You can refer to this documentation - Quickstart - PlayFab Client library for C# - PlayFab | Microsoft Docs to learn more about our C# SDK. In PlayFab C# SDK, the calls of server API are enabled by default.

Besides, if you use Unity as the development platform of clients. Our PlayFab Unity SDK contains the method definition of ExecuteFunction for player to execute Azure Functions.

>> i assume i have to just paste the http result in and the function name, wondering if i have to first register that to the azure website or if i can just do it without registration, just via playfab.

To use the backend service that provide by Aure Functions, you must deploy it to Azure first, then register it to PlayFab. Azure Functions documentation - Create a C# function using Visual Studio Code - Azure Functions | Microsoft Docs and our documentation - PlayFab CloudScript using Azure Functions Quickstart Guide - PlayFab | Microsoft Docs will provide you with guidance. You can also check out our overview video - PlayFab + Azure Functions + Visual Studio Code - Crazy Awesome Games! - YouTube.

If you want to locally test it before you deploy it to Azure, you can follow this documentation - Local debugging for Cloudscript using Azure Functions - PlayFab | Microsoft Docs to do the locally debugging. For clarification, locally debugging of Azure Functions also depends on Azure Functions core tool provided by Azure.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

khattabkhairdeen avatar image khattabkhairdeen commented ·

If the azure functions would be on a new project, how would i use the playfab api? where do i download the playfab SDK for non unity projects?

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang khattabkhairdeen commented ·

As the answer said, for C# project, you can refer to this documentation - Quickstart - PlayFab Client library for C# - PlayFab | Microsoft Docs to learn more about how to use PlayFab C# SDK.

If you need the SDK for other platforms or other languages, you can search them in our SDK documentation - Azure PlayFab SDKs - PlayFab | Microsoft Docs.

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.