Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all,
My use case is as follows: given user input (a single monetary value), I would like to optimize a set of given items.
My initial thoughts are:
1. Build a PowerApps app + connect in powerbi, that just takes user input
2. Connect to Flow -- when user input received, execute Flow (power automate)
3. This Flow will in turn run a python file that calls an optimizer library (PuLP) -- based on the input variable, and constraints, selects items that maximize that input. This may be possible using Azure Function API?
4. Then the result of that py file is sent back to Flow, and then back to powerapps somehow...
I am fairly new to powerapps / powerbi, so I'd like to get your suggestions. Is this a feasible approach highlighted above?
Solved! Go to Solution.
HI @Anonymous,
#1, You can create PowerApps with parameters, then they allow you to input parameters.
Launch and Param functions in Power Apps
#2, Please check the following link about use PowerApps with ms flow.
#3, You can do these with Azure functions, you can take a look at the below link to know more about these.
Create your first function in the Azure portal
#4, You can refer to the following blog about invoke the Azure function in flow:
Invoke an Azure Function Using Power Automate (Flow)
Regards,
Xiaoxin Sheng
Hi @Anonymous,
Sorry for the late response. Did you mean to use python to connect/manage Azure VM? If that is the case, you can refer to the following documents:
Create and manage Windows VMs in Azure using Python
Reference link about azure function network operations:
Azure Functions networking options
Regards,
Xiaoxin Sheng
HI @Anonymous,
#1, You can create PowerApps with parameters, then they allow you to input parameters.
Launch and Param functions in Power Apps
#2, Please check the following link about use PowerApps with ms flow.
#3, You can do these with Azure functions, you can take a look at the below link to know more about these.
Create your first function in the Azure portal
#4, You can refer to the following blog about invoke the Azure function in flow:
Invoke an Azure Function Using Power Automate (Flow)
Regards,
Xiaoxin Sheng
Hi @v-shex-msft ! Thanks for the great help!
Sorry about delay -- I am trying to do step3 and having this issue
"One or more errors occurred. (Error while copying content to a stream.)"
I followed step by step -- i am logged into az, I am using their HTTP Example, but still nothing worked. If you know of a fix for this, I'd appreciate it -- I will keep you updated. thanks again.
It fails at this command: func new --name HttpExample --template "HTTP trigger" --authlevel "anonymous"
HI @Anonymous,
So you mean you can't finish the create function app steps to redirect to the detail develop menu?
If this is a case, have you checked you have corresponded permissions to do operate with azure functions apps?
In addition, you can contact azure admin/support with detailed error messages and these request id to get further support.
Regards,
Xiaoxin Sheng
Hi @v-shex-msft !
Amazing, that was the issue -- thanks for your help again.
If you dont mind, I am running into an issue again. The function is now locally working, but when I try to deploy onto Azure, I get the following error traceback:
Exception while executing function: Functions.HttpExample Result: Failure
Exception: PulpSolverError: Pulp: Error while executing /home/site/wwwroot/.python_packages/lib/site-packages/pulp/apis/../solverdir/cbc/linux/64/cbc
Stack: File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 355, in _handle__invocation_request
call_result = await self._loop.run_in_executor(
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 542, in __run_sync_func
return func(**params)
File "/home/site/wwwroot/HttpExample/__init__.py", line 22, in main
return func.HttpResponse(f"{optimize(name)}")
File "/home/site/wwwroot/HttpExample/__init__.py", line 100, in optimize
model.solve(solver)
File "/home/site/wwwroot/.python_packages/lib/site-packages/pulp/pulp.py", line 1737, in solve
status = solver.actualSolve(self, **kwargs)
File "/home/site/wwwroot/.python_packages/lib/site-packages/pulp/apis/coin_api.py", line 101, in actualSolve
return self.solve_CBC(lp, **kwargs)
File "/home/site/wwwroot/.python_packages/lib/site-packages/pulp/apis/coin_api.py", line 159, in solve_CBC
raise PulpSolverError("Pulp: Error while executing "+self.path)
Based on this file: https://github.com/coin-or/pulp/blob/master/pulp/apis/coin_api.py
It looks like it fails here on line 158/9:
if not os.path.exists(tmpSol):
raise PulpSolverError("Pulp: Error while executing "+self.path)
maybe when deploying, it doesnt have / cant find the os path?
Couldn't find the same issue on the web, except this: https://github.com/Azure/azure-functions-python-worker/issues/465 which suggests using Docker --
but is there an alternative to Docker? how should I proceed?
thanks for your help
ah, please ignore -- i fiex with parameter keepFiles=True
I now have this issue lol
Exception while executing function: Functions.HttpExample Result: Failure
Exception: OSError: [Errno 30] Read-only file system: 'Budget_model-pulp.mps'
Stack: File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 355, in _handle__invocation_request
call_result = await self._loop.run_in_executor(
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 542, in __run_sync_func
return func(**params)
File "/home/site/wwwroot/HttpExample/__init__.py", line 22, in main
return func.HttpResponse(f"{optimize(name)}")
File "/home/site/wwwroot/HttpExample/__init__.py", line 100, in optimize
model.solve(solver)
File "/home/site/wwwroot/.python_packages/lib/site-packages/pulp/pulp.py", line 1737, in solve
status = solver.actualSolve(self, **kwargs)
File "/home/site/wwwroot/.python_packages/lib/site-packages/pulp/apis/coin_api.py", line 101, in actualSolve
return self.solve_CBC(lp, **kwargs)
File "/home/site/wwwroot/.python_packages/lib/site-packages/pulp/apis/coin_api.py", line 114, in solve_CBC
vs, variablesNames, constraintsNames, objectiveName = lp.writeMPS(tmpMps, rename = 1)
File "/home/site/wwwroot/.python_packages/lib/site-packages/pulp/pulp.py", line 1611, in writeMPS
return mpslp.writeMPS(self, filename, mpsSense = mpsSense, rename = rename, mip = mip)
File "/home/site/wwwroot/.python_packages/lib/site-packages/pulp/mps_lp.py", line 223, in writeMPS
with open(filename, "w") as f:
i understand i cant write to the azure fn directory -- but im wondering how its possible to work around this if its in a library im calling -- maybe create a blob storage for this "filename" -- will have to keep digging into it
i'm trying to play around wtih some parameters when calling the function that is in the pulp library, no luck yet - will keep you posted
HI @Anonymous,
>>i understand i can't write to the azure fn directory -- but im wondering how its possible to work around this if its in a library im calling -- maybe create a blob storage for this "filename" -- will have to keep digging into it
Yes, detect the physical file/directory path operations on business cloud servers should be a pain to process.
AFAIK, these types of operations almost blocked by permissions, policy, and security reasons except you are working on personal servers.
One workaround is to use a temporary server/service which you have enough permissions to manage and configurations to do these sensitive operations. (azure side do simple read/write operations)
Steps:
Azuree Server:
1. Common operate
2. Common operate
3. Common operate
Azure server to temporary server:
1. Sensitive operations
2. Loading result data to Azure Server
Azuree Server:
4. Common operate
5. Common operate
6. Common operate
Regards,
Xiaoxin Sheng
hi @v-shex-msft ,
great, do you think I'll be able to use a non-azure Windows VM? if so, I'd appreciate documentation / examples -- seems like we might need VNet integration?
HI @Anonymous,
In fact, this temporary server/service not has limits on device types.
You can even deploy these on your personal laptop/PC if you can confirm it worked online and has permission to receiver these remote operations and requests.😊
Notice:
Above is a sample, you can use it to do tests but please not really deploy it to your personal laptops. It is are hard to confirm their status(device hardware, network, and power status) and keep working online every time.
Regards,
Xiaoxin Sheng
amazing @v-shex-msft ! do you know where I can find examples of connecting to VM?
Hi @Anonymous,
Sorry for the late response. Did you mean to use python to connect/manage Azure VM? If that is the case, you can refer to the following documents:
Create and manage Windows VMs in Azure using Python
Reference link about azure function network operations:
Azure Functions networking options
Regards,
Xiaoxin Sheng
Hi @Anonymous,
Normally you can do these with two methods, connect with RDP(Remote Desktop Protocol) or deploy web service on your device.
For your scenario, I think web service should suitable for your requirement.
Configuring a Web Server for Web Deploy Publishing (Web Deploy Handler)
Regards,
Xiaoxin Sheng
is there a way to avoid powerapps ?
Hi @Anonymous,
So you mean you want to directly use ms flow to invoke python script and azure functions without power app?
If this is the case, you can directly use ms flow to do these things without the power app. The first two steps not necessary in these operations, you can avoid them and only use ms flow.
Regards,
Xiaoxin Sheng
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
12 | |
2 | |
2 | |
1 | |
1 |