Change Azure Cloud Service environment variable without publishing - azure

Is it possible to change an environment variable on an Azure Cloud Service without publishing? I'd like to be able to change a variable and then restart my app, but I don't need to re-deploy.

To change the configuration settings in the portal, login into the portal (Please note that currently the preview portal does not support cloud services) and the select your cloud service and then click on CONFIGURE tab. You will see all settings there.
You can also change the configuration settings through Azure PowerShell Cmdlets as well. So what you would do is make the change in the cscfg file and then execute Set-AzureDeployment Cmdlet. Following is an example of changing the configuration file:
Set-AzureDeployment -Config -ServiceName "MySvc1" -Slot "Staging" -Configuration "C:\Temp\MyServiceConfig.Cloud.csfg"
Some points I do want to mention in the answer:
You can only change the settings stored in *.cscfg file without redeploying your code. If there are settings in your app/web.config file which you want to change, then you would have to redeploy the application.
If you want to add new settings, then you have to redeploy the application. You can't add new settings dynamically at this time.

Related

Functions get Remove when zip deploy function app using Azure CLI or PowerShell

I'm facing an issue while deploying the azure function using Azure CLI or Azure PowerShell.
I have already created needed resources like resource group, function app and blob storage.
My function app platform type is Linux with consumption plan and runtime net6.0. I have created Service Bus trigger function and deployed using Visual Studio Publish profile and it is working as expected.
But when I executed the command to deploy the Azure function using CLI. Command is executing successfully but when I open the function app from azure portal and go to functions blade the deployed functions do not appear there.
I also checked the folder structure of the build output as mentioned in the link
https://learn.microsoft.com/en-us/azure/azure-functions/deployment-zip-push
any help would be appreciated.
Thanks
Reproduced the same issue from our end using Az-CLI
az functionapp deployment source config-zip -g <Resource Group> -n <Function App Name> --src <Function Project with Zip>
Workaround to fix the issue
After setting SCM_DO_BUILD_DURING_DEPLOYMENT to true in Configuration > Application Settings of the Azure Function App in Portal and deployed again using AZ CLI commands and shown the functions in Portal and in Kudu site of wwwroot folder.
AZ CLI Command:
az functionapp deployment source config-zip -g HariTestRG -n KrishNet6FuncApp --src "C:/Users/Hari/source/repos/DotNet6/TimerTrigger1205.zip"
According to this MS DOC, we came to know that some deployment customization has to be done before deploying the Function App as a Zip Push, i.e., by default the app setting SCM_DO_BUILD_DURING_DEPLOYMENT is false which enables the continuous integration deployment.
For the PowerShell Workaround, refer GitHub Page.
Function App running on Linux OS in consumption plan has limited deployment options but supports only remote build.
To enable remote build on Linux, the following application settings must be set:
ENABLE_ORYX_BUILD=true
SCM_DO_BUILD_DURING_DEPLOYMENT=true
If your project needs to use remote build, don't use the
WEBSITE_RUN_FROM_PACKAGE app setting.
Functions Core Tools is the only solution work for me.
By default, Azure Functions Core Tool perform remote builds when deploying to Linux. Because of this, it automatically create these settings for you in Azure.
func azure functionapp publish <FunctionAppName>
my custom script file
param(
[Parameter(Mandatory=$True)]
$AppName,
[Parameter(Mandatory=$True)]
$LocalProjectPath
)
cd "$($LocalProjectPath)"
func azure functionapp publish $AppName
cd ..
if you need more help with Linux hosting use this link Zip Deploymnet to get detailed information related to Azure Functions Deployments.

App Service Key Vault Reference breaks when re-deploying ARM template

I have an Azure App Service Web App using Key Vault References for several application settings. All resources are deployed and configured through an Bicep/ARM template. The secrets in Key Vault and Access Policies are set through the Bicep/ARM template as well. The Web App works great and has access to Key Vault through those references until I re-deploy the Bicep / ARM template to modify some unrelated values. After running "az deployment group create" the references break (showing red cross in application settings). I found two workarounds to make them connect again:
Restart Web App
Create another app setting / modify a setting in the portal and save
I would like to understand the root cause / possible mistake and why the work-arrounds help. I checked, and the Secrets in Key Vault are not changed / updated when re-deploying the template. My assumption is that this is caused by the Key Vault API removing and re-creating the Access Policies each time the template gets deployed. A what-if deployment of the template tells me that the removal and re-creation of the Access Policies is happening.
As mentioned by #Deepdave in the comment section. ARM does not allow a key vault to be redeployed with out clearing existing access polices.
Please submit your feedback here https://feedback.azure.com/forums/34192--general-feedback

How can i remove the Azure WebApp AppSetting WEBSITE_TIME_ZONE

when I delete the AppSetting "WEBSITE_TIME_ZONE" in my Azure Webapp (Linux), it is there again after refreshing.
I can delete other AppSettings without problems, but this particular entry keeps coming back.
This is how I proceed. I delete the setting "WEBSITE_TIME_ZONE" via the trash can button, click on Save (then the entry is gone), then I click on Refresh and then the entry shows up again.
Has anyone had this problem and can help me?
Please try deleting that specific app setting via the command line.
az webapp config appsettings delete is the Azure CLI command:
az webapp config appsettings delete --name <your-webapp-name> --resource-group <resource-group> --setting-names <setting-names>
P.S.: You can use the Azure Cloud Shell if you do not have Azure CLI installed on your machine.

Deploy of Arm Template with Logic Apps throws Error : Data sinks can’t be reused in different settings on the same category for the same resource

So I have setup a deployment of an Arm Template with some Logic Apps with some related diagnostic setting for Event hub, see img.
Event Hub Settings
However, when deploying the same template again, we get the error: "Data sinks can’t be reused in different settings on the same category for the same resource".
And the solution is to remove the diagnostic settings before a new deploy. But I don't want to manually do this each time we do a new deploy.
Have someone figured out a workaround for this?
Thanks!
You can either use PowerShell command or Azure CLI command to remove a diagnostic setting for the resource.
PowerShell command (You can find the documentation here):
Remove-AzDiagnosticSetting -ResourceId "Resource01" -Name myDiagSetting
Azure CLI command (You can find documentation here):
az monitor diagnostic-settings delete --name "myDiagSetting" --resource "Resource01"

Changing Azure web role name?

Is it possible to change a web role name through PowerShell or any other programmatic way without needing to change the project name itself? We need role name change for monitoring purpose and changing project name would require a lot of work for us with modifying build definitions.
There seems to be a work around way which is from a blog of a MS developer, to update role name via modify the Role schema file.
Hope it helps.
Rename Azure Cloud Service.ps1
import-module Azure
# download publish settings
Get-AzurePublishSettingsFile
# import settings you just downloaded
Import-AzurePublishSettingsFile "C:\Users\<user>\Downloads\MySub-DATE-credentials.publishsettings"
# view subscription details
Get-AzureSubscription
# select active subscription
Select-AzureSubscription 'MySub'
# view cloud services for selected sub
Get-AzureService
# update cloud service name/description
Set-AzureService 'myServiceName' 'Friendly Service Name' 'Detailed Service Description'

Resources