Month: August 2024
How to update a function with output from another function?
I am trying to solve for heat transfer coefficients so that I can use them to calculate gas and tank wall temperatures. Currently, I am using constant heat transfer coefficients to enable the calculation of the desired temperatures with ode45.
% Convective heat transfer coefficients
h_in = 25; % Convective heat transfer coefficient inside the tank (W/(m^2·K))
h_out = 6; % Convective heat transfer coefficient outside the tank (W/(m^2·K))
% Solve the coupled ODEs and PDE
[t, y] = ode45(@(t, y) odes(t, y, R, C_p_gas, k_liner, k_CFRP, rho_liner, rho_CFRP, C_p_liner, C_p_CFRP, h_in, h_out, T_ambient, A_in, A_out, dx_liner, dx_CFRP, N_liner, N_CFRP, V, mdot_out), tspan, initial_conditions);
% Extract time histories for inside and outside wall temperatures
T_wall_liner_interface = y(:,3); % Inside wall temperature (first point of the liner)
T_wall_CFRP_interface = y(:,end); % Outside wall temperature (last point of the CFRP layer)
What I would like to do is to use the output temperatures from the ode45 to solve for h_in and h_out, which will in turn be used by ode45 to solve for new temperatures. The h_in and h_out calculations look like this:
function [h_in, h_out]=heat_transfer_coefficients
Di = 0.230; % Internal diameter in meters
Do = 0.279; % External diameter in meters
T_gf = 266.17; %(K) – Type III hydrogen gas T at film temp
rho_gf = 39.16; %(kg/m^3) – Type III hydrogen gas density @ T_gf
Cp_gf = 0.01514*((T_gf/100)^4.789)+1002;
mu_gf = (-4.127*10^-7)*((T_gf/100)^2)+((7.258*10^-6)*(T_gf/100))+(4.094*10^-7);
lambda_gf = ((-3.77*10^-4)*(T_gf/100)^2)+((1.004*10^-2)*(T_gf/100))-(4.776*10^-4);
beta_gf = 1/T_gf; %volumetric thermal expansion coefficient
g = 9.81; %gravitational acceleration (m/s^2)
Rai = (rho_gf^2*(Di^3)*beta_gf*g*(T_wall_liner_interface-T_gas)*Cp_gf)/(mu_gf*lambda_gf); %Rayleigh number at inner wall
if Rai < 10^8
Nu_i = 1.15*Rai.^0.22;
else
Nu_i = 0.14*Rai.^0.333;
end
ki = 168.9e3; %thermal conductivity inside tank at T_g, Type III (W/m*K)
h_in = (Nu_i*ki)/Di;
T_ambf = 279.43; %(K) – Type III
rho_ambf = 1.263; %(kg/m^3) – density @ T_ambf
c_wind = 0; %(m/s) – cross wind velocity
Cp_ambf = 0.01514*((T_ambf/100)^4.789)+1002;
mu_ambf = (-4.127*10^-7)*((T_ambf/100)^2)+((7.258*10^-6)*(T_ambf/100))+(4.094*10^-7);
lambda_ambf = ((-3.77*10^-4)*(T_ambf/100)^2)+((1.004*10^-2)*(T_ambf/100))-(4.776*10^-4);
beta_ambf = 1/T_ambf; %volumetric thermal expansion coefficient
Re_Do = (rho_ambf*c_wind*Do)/(mu_ambf);
Pr_ambf = (mu_ambf*Cp_ambf)/lambda_ambf;
if Re_Do == 0
Nu_cylforced = 0;
Nu_sphforced = 0;
else
Nu_cylforced = 0.3+((0.62*(Re_Do^0.5)*(Pr_ambf^(1/3)))/(1+(0.4/((Pr_ambf))^(2/3)))^(1/4))…
*(1+(Re_Do/282000)^5/8)^4/5;
Nu_sphforced = 2 + ((Re_Do/4)+((3*10^-4)*Re_Do^1.6))^0.5;
end
Rao = (rho_ambf^2*(Do^3)*beta_ambf*g*(T_amb-T_wall_CFRP_interface)*Cp_ambf)/(mu_ambf*lambda_ambf); %Rayleigh number at inner wall
Nu_oforced = ((Nu_cylforced*0.72)+(Nu_sphforced*0.24))/(0.72+0.24);
Nu_ofree = (0.6+((0.387*(Rao.^(1/6)))/(1+(0.559/Pr_ambf)^(9/16)).^(8/27))).^2;
Nu_o = ((Nu_ofree.^4)+(Nu_oforced^4)).^0.25;
ko = 24.84e3; %thermal conductivity outside tank at T_wo, Type III (W/m*K)
h_out = (Nu_o*ko)/Do;
end
As can be seen in the above code, the h_in and h_out calculations require T_gas, T_wall_liner interface and T_wall_CFRP_interface, which currently are being calculated after h_in and h_out. Can somebody please show me a way I can incorporate the h_in and h_out calculations into the first section of code? For ease of explanation and solving, please feel free to use your own numbers for the constants in the ode45 solver line.I am trying to solve for heat transfer coefficients so that I can use them to calculate gas and tank wall temperatures. Currently, I am using constant heat transfer coefficients to enable the calculation of the desired temperatures with ode45.
% Convective heat transfer coefficients
h_in = 25; % Convective heat transfer coefficient inside the tank (W/(m^2·K))
h_out = 6; % Convective heat transfer coefficient outside the tank (W/(m^2·K))
% Solve the coupled ODEs and PDE
[t, y] = ode45(@(t, y) odes(t, y, R, C_p_gas, k_liner, k_CFRP, rho_liner, rho_CFRP, C_p_liner, C_p_CFRP, h_in, h_out, T_ambient, A_in, A_out, dx_liner, dx_CFRP, N_liner, N_CFRP, V, mdot_out), tspan, initial_conditions);
% Extract time histories for inside and outside wall temperatures
T_wall_liner_interface = y(:,3); % Inside wall temperature (first point of the liner)
T_wall_CFRP_interface = y(:,end); % Outside wall temperature (last point of the CFRP layer)
What I would like to do is to use the output temperatures from the ode45 to solve for h_in and h_out, which will in turn be used by ode45 to solve for new temperatures. The h_in and h_out calculations look like this:
function [h_in, h_out]=heat_transfer_coefficients
Di = 0.230; % Internal diameter in meters
Do = 0.279; % External diameter in meters
T_gf = 266.17; %(K) – Type III hydrogen gas T at film temp
rho_gf = 39.16; %(kg/m^3) – Type III hydrogen gas density @ T_gf
Cp_gf = 0.01514*((T_gf/100)^4.789)+1002;
mu_gf = (-4.127*10^-7)*((T_gf/100)^2)+((7.258*10^-6)*(T_gf/100))+(4.094*10^-7);
lambda_gf = ((-3.77*10^-4)*(T_gf/100)^2)+((1.004*10^-2)*(T_gf/100))-(4.776*10^-4);
beta_gf = 1/T_gf; %volumetric thermal expansion coefficient
g = 9.81; %gravitational acceleration (m/s^2)
Rai = (rho_gf^2*(Di^3)*beta_gf*g*(T_wall_liner_interface-T_gas)*Cp_gf)/(mu_gf*lambda_gf); %Rayleigh number at inner wall
if Rai < 10^8
Nu_i = 1.15*Rai.^0.22;
else
Nu_i = 0.14*Rai.^0.333;
end
ki = 168.9e3; %thermal conductivity inside tank at T_g, Type III (W/m*K)
h_in = (Nu_i*ki)/Di;
T_ambf = 279.43; %(K) – Type III
rho_ambf = 1.263; %(kg/m^3) – density @ T_ambf
c_wind = 0; %(m/s) – cross wind velocity
Cp_ambf = 0.01514*((T_ambf/100)^4.789)+1002;
mu_ambf = (-4.127*10^-7)*((T_ambf/100)^2)+((7.258*10^-6)*(T_ambf/100))+(4.094*10^-7);
lambda_ambf = ((-3.77*10^-4)*(T_ambf/100)^2)+((1.004*10^-2)*(T_ambf/100))-(4.776*10^-4);
beta_ambf = 1/T_ambf; %volumetric thermal expansion coefficient
Re_Do = (rho_ambf*c_wind*Do)/(mu_ambf);
Pr_ambf = (mu_ambf*Cp_ambf)/lambda_ambf;
if Re_Do == 0
Nu_cylforced = 0;
Nu_sphforced = 0;
else
Nu_cylforced = 0.3+((0.62*(Re_Do^0.5)*(Pr_ambf^(1/3)))/(1+(0.4/((Pr_ambf))^(2/3)))^(1/4))…
*(1+(Re_Do/282000)^5/8)^4/5;
Nu_sphforced = 2 + ((Re_Do/4)+((3*10^-4)*Re_Do^1.6))^0.5;
end
Rao = (rho_ambf^2*(Do^3)*beta_ambf*g*(T_amb-T_wall_CFRP_interface)*Cp_ambf)/(mu_ambf*lambda_ambf); %Rayleigh number at inner wall
Nu_oforced = ((Nu_cylforced*0.72)+(Nu_sphforced*0.24))/(0.72+0.24);
Nu_ofree = (0.6+((0.387*(Rao.^(1/6)))/(1+(0.559/Pr_ambf)^(9/16)).^(8/27))).^2;
Nu_o = ((Nu_ofree.^4)+(Nu_oforced^4)).^0.25;
ko = 24.84e3; %thermal conductivity outside tank at T_wo, Type III (W/m*K)
h_out = (Nu_o*ko)/Do;
end
As can be seen in the above code, the h_in and h_out calculations require T_gas, T_wall_liner interface and T_wall_CFRP_interface, which currently are being calculated after h_in and h_out. Can somebody please show me a way I can incorporate the h_in and h_out calculations into the first section of code? For ease of explanation and solving, please feel free to use your own numbers for the constants in the ode45 solver line. I am trying to solve for heat transfer coefficients so that I can use them to calculate gas and tank wall temperatures. Currently, I am using constant heat transfer coefficients to enable the calculation of the desired temperatures with ode45.
% Convective heat transfer coefficients
h_in = 25; % Convective heat transfer coefficient inside the tank (W/(m^2·K))
h_out = 6; % Convective heat transfer coefficient outside the tank (W/(m^2·K))
% Solve the coupled ODEs and PDE
[t, y] = ode45(@(t, y) odes(t, y, R, C_p_gas, k_liner, k_CFRP, rho_liner, rho_CFRP, C_p_liner, C_p_CFRP, h_in, h_out, T_ambient, A_in, A_out, dx_liner, dx_CFRP, N_liner, N_CFRP, V, mdot_out), tspan, initial_conditions);
% Extract time histories for inside and outside wall temperatures
T_wall_liner_interface = y(:,3); % Inside wall temperature (first point of the liner)
T_wall_CFRP_interface = y(:,end); % Outside wall temperature (last point of the CFRP layer)
What I would like to do is to use the output temperatures from the ode45 to solve for h_in and h_out, which will in turn be used by ode45 to solve for new temperatures. The h_in and h_out calculations look like this:
function [h_in, h_out]=heat_transfer_coefficients
Di = 0.230; % Internal diameter in meters
Do = 0.279; % External diameter in meters
T_gf = 266.17; %(K) – Type III hydrogen gas T at film temp
rho_gf = 39.16; %(kg/m^3) – Type III hydrogen gas density @ T_gf
Cp_gf = 0.01514*((T_gf/100)^4.789)+1002;
mu_gf = (-4.127*10^-7)*((T_gf/100)^2)+((7.258*10^-6)*(T_gf/100))+(4.094*10^-7);
lambda_gf = ((-3.77*10^-4)*(T_gf/100)^2)+((1.004*10^-2)*(T_gf/100))-(4.776*10^-4);
beta_gf = 1/T_gf; %volumetric thermal expansion coefficient
g = 9.81; %gravitational acceleration (m/s^2)
Rai = (rho_gf^2*(Di^3)*beta_gf*g*(T_wall_liner_interface-T_gas)*Cp_gf)/(mu_gf*lambda_gf); %Rayleigh number at inner wall
if Rai < 10^8
Nu_i = 1.15*Rai.^0.22;
else
Nu_i = 0.14*Rai.^0.333;
end
ki = 168.9e3; %thermal conductivity inside tank at T_g, Type III (W/m*K)
h_in = (Nu_i*ki)/Di;
T_ambf = 279.43; %(K) – Type III
rho_ambf = 1.263; %(kg/m^3) – density @ T_ambf
c_wind = 0; %(m/s) – cross wind velocity
Cp_ambf = 0.01514*((T_ambf/100)^4.789)+1002;
mu_ambf = (-4.127*10^-7)*((T_ambf/100)^2)+((7.258*10^-6)*(T_ambf/100))+(4.094*10^-7);
lambda_ambf = ((-3.77*10^-4)*(T_ambf/100)^2)+((1.004*10^-2)*(T_ambf/100))-(4.776*10^-4);
beta_ambf = 1/T_ambf; %volumetric thermal expansion coefficient
Re_Do = (rho_ambf*c_wind*Do)/(mu_ambf);
Pr_ambf = (mu_ambf*Cp_ambf)/lambda_ambf;
if Re_Do == 0
Nu_cylforced = 0;
Nu_sphforced = 0;
else
Nu_cylforced = 0.3+((0.62*(Re_Do^0.5)*(Pr_ambf^(1/3)))/(1+(0.4/((Pr_ambf))^(2/3)))^(1/4))…
*(1+(Re_Do/282000)^5/8)^4/5;
Nu_sphforced = 2 + ((Re_Do/4)+((3*10^-4)*Re_Do^1.6))^0.5;
end
Rao = (rho_ambf^2*(Do^3)*beta_ambf*g*(T_amb-T_wall_CFRP_interface)*Cp_ambf)/(mu_ambf*lambda_ambf); %Rayleigh number at inner wall
Nu_oforced = ((Nu_cylforced*0.72)+(Nu_sphforced*0.24))/(0.72+0.24);
Nu_ofree = (0.6+((0.387*(Rao.^(1/6)))/(1+(0.559/Pr_ambf)^(9/16)).^(8/27))).^2;
Nu_o = ((Nu_ofree.^4)+(Nu_oforced^4)).^0.25;
ko = 24.84e3; %thermal conductivity outside tank at T_wo, Type III (W/m*K)
h_out = (Nu_o*ko)/Do;
end
As can be seen in the above code, the h_in and h_out calculations require T_gas, T_wall_liner interface and T_wall_CFRP_interface, which currently are being calculated after h_in and h_out. Can somebody please show me a way I can incorporate the h_in and h_out calculations into the first section of code? For ease of explanation and solving, please feel free to use your own numbers for the constants in the ode45 solver line. function MATLAB Answers — New Questions
Unable to recognise function from called script
I created this function in a scipted named "lab1_script.m":
t = [1, 2, 3, 4]
function y = lab1_function(t, c)
y = c*t.^2;
end
But when I try to call the script in a new script as follows:
lab1_script;
y = lab1_function(t,0.1)
The error message: unrecognisable function or variable ‘lab1_function’ appears. And I know that the function works, because when I call it within the same script it is fine. It is just trying to call it into a different script that I am having trouble with.
I am confused, what am I doing wrong? Should I be calling the script a different way for the function to be recognised?
Thanks in advance! :)I created this function in a scipted named "lab1_script.m":
t = [1, 2, 3, 4]
function y = lab1_function(t, c)
y = c*t.^2;
end
But when I try to call the script in a new script as follows:
lab1_script;
y = lab1_function(t,0.1)
The error message: unrecognisable function or variable ‘lab1_function’ appears. And I know that the function works, because when I call it within the same script it is fine. It is just trying to call it into a different script that I am having trouble with.
I am confused, what am I doing wrong? Should I be calling the script a different way for the function to be recognised?
Thanks in advance! 🙂 I created this function in a scipted named "lab1_script.m":
t = [1, 2, 3, 4]
function y = lab1_function(t, c)
y = c*t.^2;
end
But when I try to call the script in a new script as follows:
lab1_script;
y = lab1_function(t,0.1)
The error message: unrecognisable function or variable ‘lab1_function’ appears. And I know that the function works, because when I call it within the same script it is fine. It is just trying to call it into a different script that I am having trouble with.
I am confused, what am I doing wrong? Should I be calling the script a different way for the function to be recognised?
Thanks in advance! 🙂 function, calling script MATLAB Answers — New Questions
Audio quality very poor – August 2024
Anyone else expereincing very ppor audio quality on Teams calls recently?
My experience is
– no problem connecting to calls – with both video and audio and screensharing
– randomly and on all participant – audio periodically cuts out go 1-5 seconds
– happens on all Teams meetings over last couple of weeks
……..so it sounds like a Microsoft issue
Any and all solutions very welcome
Anyone else expereincing very ppor audio quality on Teams calls recently?My experience is- no problem connecting to calls – with both video and audio and screensharing- randomly and on all participant – audio periodically cuts out go 1-5 seconds- happens on all Teams meetings over last couple of weeks ……..so it sounds like a Microsoft issue Any and all solutions very welcome Read More
Excel Table List, Property Columns disappearing in Power Query
Previously the File Contents of the Source files would display like this in Power Query
And recently the file contents displays like this in Power Query. Which is missing the Columns for Item, Kind and Hidden
The result is that all the Power Queries that used to work are now breaking. If anyone can help me crack this case it would be hugely appreciated, I cant change my query because I need to combine the data from the old files and the new files.
I am running Excel Version 2407 Build 16.0.17830.20056) 32-bit
I have a number of Source data Excel Files which all have an identical structure. All have the same queries that load into the files and the same named ranges. I have checked and all the queries have the same privacy setting of Organizational. Previously the File Contents of the Source files would display like this in Power Query And recently the file contents displays like this in Power Query. Which is missing the Columns for Item, Kind and Hidden The result is that all the Power Queries that used to work are now breaking. If anyone can help me crack this case it would be hugely appreciated, I cant change my query because I need to combine the data from the old files and the new files. I am running Excel Version 2407 Build 16.0.17830.20056) 32-bit Read More
REST endpoint for querying in log traces (kusto based)
Do anyone here know if there exists a REST endpoint for querying in log traces (kusto based) like this sample:
traces
| where timestamp > ago(60m)
| parse message with xx “instance=” instance “,” yy
| summarize [‘instances’] = dcount(instance) by bin(timestamp, 60sec)
It works in Azure portal but I would like to execute the query programmatically and not through a UI.
/kristian
Do anyone here know if there exists a REST endpoint for querying in log traces (kusto based) like this sample: traces| where timestamp > ago(60m)| parse message with xx “instance=” instance “,” yy| summarize [‘instances’] = dcount(instance) by bin(timestamp, 60sec) It works in Azure portal but I would like to execute the query programmatically and not through a UI. /kristian Read More
What does it mean by the premium version of Word?
This message pops up from time to time. I am currently using 2017 Professional.
This message pops up from time to time. I am currently using 2017 Professional. Read More
Any easy way to clean up the app list for speeding up the PC?
It is a huge app list from checking the task manager. And I don’t even know some of the apps. How to delete them in bulk?
It is a huge app list from checking the task manager. And I don’t even know some of the apps. How to delete them in bulk? Read More
Is Window 10 still worth having?
I’ve started to wonder if it’s time to consider switching to a different operating system. I value simplicity and reliability over fancy features, and I’m starting to feel like Windows 10 is no longer meeting my needs. Has anyone else had similar experiences or concerns about Windows 10? Are there any other operating systems out there that might be a better fit for me?
I’ve started to wonder if it’s time to consider switching to a different operating system. I value simplicity and reliability over fancy features, and I’m starting to feel like Windows 10 is no longer meeting my needs. Has anyone else had similar experiences or concerns about Windows 10? Are there any other operating systems out there that might be a better fit for me? Read More
Windows 10 laptops are making buzzing noise
I’ve recently noticed that my Windows 10 computer has been making a strange buzzing noise when I’m using it. The buzzing is quite loud and can be heard even when the volume is turned down. It’s not a constant noise, but rather comes and goes depending on what I’m doing on the computer. Sometimes it’s really loud and other times it’s barely audible. I’ve tried to troubleshoot the issue, but so far, I haven’t been able to identify what’s causing it. I’ve checked for any loose connections, updated my drivers, and run disk checks, but nothing seems to be working.
I’ve recently noticed that my Windows 10 computer has been making a strange buzzing noise when I’m using it. The buzzing is quite loud and can be heard even when the volume is turned down. It’s not a constant noise, but rather comes and goes depending on what I’m doing on the computer. Sometimes it’s really loud and other times it’s barely audible. I’ve tried to troubleshoot the issue, but so far, I haven’t been able to identify what’s causing it. I’ve checked for any loose connections, updated my drivers, and run disk checks, but nothing seems to be working. Read More
Containerising Azure Functions without Dockerfile
In my previous post, I discussed different containerising options for .NET developers. Now, let’s slightly move the focus to Azure Functions app. How can you containerise the Azure Functions app? Fortunately, Azure Functions Core Tools natively support it with Dockerfile. But is the Dockerfile the only option for containerising your .NET-based Azure Functions apps? Throughout this post, I’m going to discuss how Azure Functions apps can be containerised both with and without Dockerfile.
You can find a sample code from this GitHub repository.
Prerequisites
There are a few prerequisites to containerise .NET-based function apps effectively.
.NET SDK 8.0+
Azure Functions Core Tools
Visual Studio or Visual Studio Code + C# Dev Kit + Azure Functions
Docker Desktop
Containerise with Dockerfile
With the Azure Functions Core Tools, you can create a new Azure Functions app with the following command:
func init FunctionAppWithDockerfile
–worker-runtime dotnet-isolated
–docker
–target-framework net8.0
You may notice the –docker option in the command. This option creates a Dockerfile in the project directory. The Dockerfile looks like this:
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS installer-env
COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app &&
mkdir -p /home/site/wwwroot &&
dotnet publish *.csproj –output /home/site/wwwroot
# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0-appservice
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY –from=installer-env [“/home/site/wwwroot”, “/home/site/wwwroot”]
There are a few points on Dockerfile to pick up:
The base image for the runtime is mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0. There are two other options available, mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0-slim and mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0-mariner. You can choose one of them based on your requirements.
The function app is running on the /home/site/wwwroot directory.
It has two environment variables, AzureWebJobsScriptRoot and AzureFunctionsJobHost__Logging__Console__IsEnabled.
There’s no ENTRYPOINT instruction defined.
These points will be used later on this post.
Let’s add a new function to the Azure Functions app with the following command:
func new -n HttpExampleTrigger -t HttpTrigger -a anonymous
Once it’s added, open the HttpExampleTrigger.cs file and modify it as follows:
// Before
return new OkObjectResult(“Welcome to Azure Functions!”);
// After
return new OkObjectResult(“Welcome to Azure Functions with Dockerfile!”);
Now, you can build the container image with the following command:
docker build . -t funcapp:latest-dockerfile
You have the container image for the Azure Functions app. You can run the container with the following command:
docker run -d -p 7071:80 –name funcappdockerfile funcapp:latest-dockerfile
Your function app is now up and running in a container. Open the browser and navigate to http://localhost:7071/api/HttpExampleTrigger to see the function app running.
Open your Docker Desktop and check the running container.
Can you see the Path and Args value? The Path value is /opt/startup/start_nonappservice.sh and the Args value is an empty array. In other words, the shell script, start_nonappservice.sh is run when the container starts, and it takes no arguments. Keep this information in mind. You’ll use it later in this post.
Once you’re done, stop and remove the container with the following commands:
docker stop funcappdockerfile && docker rm funcappdockerfile
So far, we’ve containerised the Azure Functions app with the Dockerfile. But, as I mentioned before, there is another way to containerise the Azure Functions app without having Dockerfile. Let’s move on.
Containerise with dotnet publish
Because MSBuild natively supports containerisation, you can make use of the dotnet publish command to build the container image for your function app. If you want to dynamically set the base container image, this option will be really useful. To do this, you might need to update your .csproj file to include the containerisation settings. First of all, create a new function app without the –docker option.
func init FunctionAppWithMSBuild
–worker-runtime dotnet-isolated
–target-framework net8.0
Let’s add a new function to the Azure Functions app with the following command:
func new -n HttpExampleTrigger -t HttpTrigger -a anonymous
Once it’s added, open the HttpExampleTrigger.cs file and modify it as follows:
// Before
return new OkObjectResult(“Welcome to Azure Functions!”);
// After
return new OkObjectResult(“Welcome to Azure Functions with MSBuild!”);
Now, the fun part begins. Open the FunctionAppWithMSBuild.csproj file and add the following node:
<ItemGroup>
<ContainerEnvironmentVariable
Include=”AzureWebJobsScriptRoot” Value=”/home/site/wwwroot” />
<ContainerEnvironmentVariable
Include=”AzureFunctionsJobHost__Logging__Console__IsEnabled” Value=”true” />
</ItemGroup>
Did you find that these two environment variables are the same as the ones in the Dockerfile? Let’s add another node to the .csproj file:
<ItemGroup Label=”ContainerAppCommand Assignment”>
<ContainerAppCommand Include=”/opt/startup/start_nonappservice.sh” />
</ItemGroup>
This node specifies the command to run when the container starts. This is the same as the Path value in the Docker Desktop screenshot. Now, you can build the container image with the following command:
dotnet publish ./FunctionAppWithMSBuild
-t:PublishContainer
–os linux –arch x64
-p:ContainerBaseImage=mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0
-p:ContainerRepository=funcapp
-p:ContainerImageTag=latest-msbuild
-p:ContainerWorkingDirectory=”/home/site/wwwroot”
NOTE: You can set the base container image with mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0-slim or mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0-mariner, depending on your requirements.
This command takes four properties – ContainerBaseImage, ContainerRepository, ContainerImageTag, and ContainerWorkingDirectory. With this dotnet publish command, you have the same development experience as building the container image with the docker build command, without having to rely on Dockerfile.
Run the following command to run the container:
docker run -d -p 7071:80 –name funcappmsbuild funcapp:latest-msbuild
Your function app is now up and running in a container. Open the browser and navigate to http://localhost:7071/api/HttpExampleTrigger to see the function app running.
Open your Docker Desktop and check the running container.
Can you see the Path and Args value? The Path value is /opt/startup/start_nonappservice.sh and the Args value has dotnet and FunctionAppWithMSBuild.dll. But these arguments are ignored because the shell script doesn’t take any argument.
Once you’re done, stop and remove the container with the following commands:
docker stop funcappmsbuild && docker rm funcappmsbuild
Now, you’ve got the Azure Functions app containerised without Dockerfile. With this dotnet publish approach, you can easily change the base container image, repository, tag, and working directory without relying on Dockerfile.
So far, I’ve walked through how .NET developers can containerise their .NET-based Azure Functions apps with two different options. You can either write Dockerfiles or use dotnet publish to build container images. Which one do you prefer?
More about MSBuild for Containers?
If you want to learn more options about containers with MSBuild, the following links might be helpful.
.NET Aspire
Containerise a .NET app with dotnet publish
.NET container images
This article was originally published on Dev Kimchi.
Microsoft Tech Community – Latest Blogs –Read More
Detecting residential areas in maps
Hello, trying to understand which strategy works best here.
I am using the mapping toolbox for a research project, which includes the calculation of the average distance/time for traveling from a number of polygonal ROIs (e.g. area of cities) to a given destination. This will in turn provide a measurement for the average cost that residents in the ROI have to endure in order to travel to the destination.
My script goes:
Consider one boundary polygon and geolocate it.
Build a grid of equally spaced geopoints within the polygon.
For each point in step 2, query the OSRM routing engine to the destination and store the response.
Average the distances/times.
I don’t like the current version of step 4, as the algorithm is applying the same weight to points in downtown and in the deep countryside. I would like to achieve a weighted average, where the weights represent a measure of the probability that someone lives nearby a given query point. This basically means detecting residential areas.
I’m not sure how to tackle this, as I’ve never worked with image processing (I’m assuming that’s the way, but I could be wrong). I thought about using geobasemap in ‘streets-light’ mode, and process the amount of pure white color in the picture, which would represent a measure of how much public road exists in a given portion of my ROI. The more roads are present, the less likely it is that we’re in the deep countryside.
I’m pretty sure there are more appropriate workarounds. Has anyone encountered a similar problem? Thank you very much.Hello, trying to understand which strategy works best here.
I am using the mapping toolbox for a research project, which includes the calculation of the average distance/time for traveling from a number of polygonal ROIs (e.g. area of cities) to a given destination. This will in turn provide a measurement for the average cost that residents in the ROI have to endure in order to travel to the destination.
My script goes:
Consider one boundary polygon and geolocate it.
Build a grid of equally spaced geopoints within the polygon.
For each point in step 2, query the OSRM routing engine to the destination and store the response.
Average the distances/times.
I don’t like the current version of step 4, as the algorithm is applying the same weight to points in downtown and in the deep countryside. I would like to achieve a weighted average, where the weights represent a measure of the probability that someone lives nearby a given query point. This basically means detecting residential areas.
I’m not sure how to tackle this, as I’ve never worked with image processing (I’m assuming that’s the way, but I could be wrong). I thought about using geobasemap in ‘streets-light’ mode, and process the amount of pure white color in the picture, which would represent a measure of how much public road exists in a given portion of my ROI. The more roads are present, the less likely it is that we’re in the deep countryside.
I’m pretty sure there are more appropriate workarounds. Has anyone encountered a similar problem? Thank you very much. Hello, trying to understand which strategy works best here.
I am using the mapping toolbox for a research project, which includes the calculation of the average distance/time for traveling from a number of polygonal ROIs (e.g. area of cities) to a given destination. This will in turn provide a measurement for the average cost that residents in the ROI have to endure in order to travel to the destination.
My script goes:
Consider one boundary polygon and geolocate it.
Build a grid of equally spaced geopoints within the polygon.
For each point in step 2, query the OSRM routing engine to the destination and store the response.
Average the distances/times.
I don’t like the current version of step 4, as the algorithm is applying the same weight to points in downtown and in the deep countryside. I would like to achieve a weighted average, where the weights represent a measure of the probability that someone lives nearby a given query point. This basically means detecting residential areas.
I’m not sure how to tackle this, as I’ve never worked with image processing (I’m assuming that’s the way, but I could be wrong). I thought about using geobasemap in ‘streets-light’ mode, and process the amount of pure white color in the picture, which would represent a measure of how much public road exists in a given portion of my ROI. The more roads are present, the less likely it is that we’re in the deep countryside.
I’m pretty sure there are more appropriate workarounds. Has anyone encountered a similar problem? Thank you very much. image processing, matlab, figure, image analysis, geobasemap MATLAB Answers — New Questions
From and Goto block connected block list?
how to find connected Corresponding From blocks list in Goto block? (Using mscript)
Similarly for From Block?how to find connected Corresponding From blocks list in Goto block? (Using mscript)
Similarly for From Block? how to find connected Corresponding From blocks list in Goto block? (Using mscript)
Similarly for From Block? from, goto block, mscript MATLAB Answers — New Questions
The Teams Mobile speed dial doesn’t show names only Numbers
For about a week now, we have had the problem on several Android phones that all external numbers are no longer displayed in the Speed dial in the Teams app.
The contacts are created and available online in the web app and can also be seen there, but in the mobile app you can only see the numbers.
However, if you click on the number in the mobile app and display the “Profile”, the name is also displayed.
For about a week now, we have had the problem on several Android phones that all external numbers are no longer displayed in the Speed dial in the Teams app.The contacts are created and available online in the web app and can also be seen there, but in the mobile app you can only see the numbers.However, if you click on the number in the mobile app and display the “Profile”, the name is also displayed. Read More
Remove password capabilities from windows
Dear Community,
Has anyone tested or explored about removing password capabilities in windows login?
Reduce the user-visible password surface area | Microsoft Learn
Please feel free to share your knowledge.
Dear Community,Has anyone tested or explored about removing password capabilities in windows login? Reduce the user-visible password surface area | Microsoft LearnPlease feel free to share your knowledge. Read More
Outlook crashing when froward email from send items
Hi Teams,
We are facing outlook crashing issue when forwarding calander invitation email with Teams attachment.
Have affected multiple users this problem. Please help me anyone faceing this issue .If anybody resolved this issue Kindly let us know the resolution.
Regards,
Senthil
Hi Teams, We are facing outlook crashing issue when forwarding calander invitation email with Teams attachment.Have affected multiple users this problem. Please help me anyone faceing this issue .If anybody resolved this issue Kindly let us know the resolution.Regards,Senthil Read More
Teams External Domain Activity Report Gets a Refresh
Microsoft says that they plan to refresh the Teams external domain activity report from September 2024. But access to the report requires a Teams Premium license. It seems like this kind of fundamental information should be available to every tenant as it’s not basic security data instead of something that could be considered as Advanced Collaboration Analytics.
https://office365itpros.com/2024/08/23/external-domain-activity-report/
Microsoft says that they plan to refresh the Teams external domain activity report from September 2024. But access to the report requires a Teams Premium license. It seems like this kind of fundamental information should be available to every tenant as it’s not basic security data instead of something that could be considered as Advanced Collaboration Analytics.
https://office365itpros.com/2024/08/23/external-domain-activity-report/ Read More
How Can I Batch Convert RAW Images to JPG on Windows?
Hey folks,
I’ve been working on editing a large collection of photos, and most of them are in RAW format straight from my camera. While RAW is great for detailed editing, I need to convert raw to jpg for easier sharing and quick edits. The thing is, I’ve got hundreds of these files and doing them one by one isn’t really an option.
I’m using a Windows PC, and I’m looking for a reliable and efficient way to batch convert RAW to JPG. I’d prefer something that’s user-friendly since I’m not super tech-savvy, but I’m open to any suggestions. Also, I’d like to preserve as much of the image quality as possible during the conversion.
Does anyone have experience with this or know of any good tools that can handle bulk conversions? Any tips or software recommendations would be awesome! Thanks a lot!
Hey folks, I’ve been working on editing a large collection of photos, and most of them are in RAW format straight from my camera. While RAW is great for detailed editing, I need to convert raw to jpg for easier sharing and quick edits. The thing is, I’ve got hundreds of these files and doing them one by one isn’t really an option. I’m using a Windows PC, and I’m looking for a reliable and efficient way to batch convert RAW to JPG. I’d prefer something that’s user-friendly since I’m not super tech-savvy, but I’m open to any suggestions. Also, I’d like to preserve as much of the image quality as possible during the conversion. Does anyone have experience with this or know of any good tools that can handle bulk conversions? Any tips or software recommendations would be awesome! Thanks a lot! Read More
Run a python exe from within a Matlab exe with Administrator permissions
I would like to run a python.exe from within a Matlab.exe file with administrator permissions.Unfortunately, the python.exe does not have the necessary permissions to write out a file. I have tried executing it directly from command prompt as administrator and it works perfectly. The process fails when I try executing it within the matlab exe. The workflow is as follows:
The python.exe receives two inputs as arguments i) filename – which is a path to a particular file ii) value
ML_correction.exe –filename "C:/…/../xx.txt" –corrected_val "-185.7"
The python exe computes a certain value and writes out a .mat file
2. The above command to call the python exe is executed within a Matlab exe as follows:
python_path="C:/…/../xx.txt";
val=-185.7;
cmd_command=[‘….ML_correction.exe –filename "’ python_path ‘" –corrected_val "’ num2str(val) ‘"’];
[status,cmdout] = system(cmd_command);
I have read the suggestions from @Jan and @Guillaume : https://de.mathworks.com/matlabcentral/answers/398700-run-external-software-from-matlab-using-system-with-admin-rights
I tried to pass my arguments using ShellExecute from Microsoft documentation but I am definitely doing it wrong. I have tried the following:
cmd_command=[‘….ML_correction.exe –filename "’ python_path ‘" –corrected_val "’ num2str(val) ‘"’];
exepath=string(cmd_command);
uac = actxserver(‘Shell.Application’);
uac.ShellExecute(exepath, "ELEV", "", "runas", 1);
Thank You!
I am using Windows 10 and Matlab2017bI would like to run a python.exe from within a Matlab.exe file with administrator permissions.Unfortunately, the python.exe does not have the necessary permissions to write out a file. I have tried executing it directly from command prompt as administrator and it works perfectly. The process fails when I try executing it within the matlab exe. The workflow is as follows:
The python.exe receives two inputs as arguments i) filename – which is a path to a particular file ii) value
ML_correction.exe –filename "C:/…/../xx.txt" –corrected_val "-185.7"
The python exe computes a certain value and writes out a .mat file
2. The above command to call the python exe is executed within a Matlab exe as follows:
python_path="C:/…/../xx.txt";
val=-185.7;
cmd_command=[‘….ML_correction.exe –filename "’ python_path ‘" –corrected_val "’ num2str(val) ‘"’];
[status,cmdout] = system(cmd_command);
I have read the suggestions from @Jan and @Guillaume : https://de.mathworks.com/matlabcentral/answers/398700-run-external-software-from-matlab-using-system-with-admin-rights
I tried to pass my arguments using ShellExecute from Microsoft documentation but I am definitely doing it wrong. I have tried the following:
cmd_command=[‘….ML_correction.exe –filename "’ python_path ‘" –corrected_val "’ num2str(val) ‘"’];
exepath=string(cmd_command);
uac = actxserver(‘Shell.Application’);
uac.ShellExecute(exepath, "ELEV", "", "runas", 1);
Thank You!
I am using Windows 10 and Matlab2017b I would like to run a python.exe from within a Matlab.exe file with administrator permissions.Unfortunately, the python.exe does not have the necessary permissions to write out a file. I have tried executing it directly from command prompt as administrator and it works perfectly. The process fails when I try executing it within the matlab exe. The workflow is as follows:
The python.exe receives two inputs as arguments i) filename – which is a path to a particular file ii) value
ML_correction.exe –filename "C:/…/../xx.txt" –corrected_val "-185.7"
The python exe computes a certain value and writes out a .mat file
2. The above command to call the python exe is executed within a Matlab exe as follows:
python_path="C:/…/../xx.txt";
val=-185.7;
cmd_command=[‘….ML_correction.exe –filename "’ python_path ‘" –corrected_val "’ num2str(val) ‘"’];
[status,cmdout] = system(cmd_command);
I have read the suggestions from @Jan and @Guillaume : https://de.mathworks.com/matlabcentral/answers/398700-run-external-software-from-matlab-using-system-with-admin-rights
I tried to pass my arguments using ShellExecute from Microsoft documentation but I am definitely doing it wrong. I have tried the following:
cmd_command=[‘….ML_correction.exe –filename "’ python_path ‘" –corrected_val "’ num2str(val) ‘"’];
exepath=string(cmd_command);
uac = actxserver(‘Shell.Application’);
uac.ShellExecute(exepath, "ELEV", "", "runas", 1);
Thank You!
I am using Windows 10 and Matlab2017b system, python exe, matlab exe MATLAB Answers — New Questions