In AZ CLI logic extension how to use integration service environment parameter - azure

We have a situation where we want to automate the logic app creation and update. We are writing a powershell to automate the deployment.
We are trying to deploy the logic app in our integration service environment.
How do we use the --integration-service-environment parameter ?
we cannot find any example on the web nor useful documentation.
In our powershell, we have the last line as follow:
az logic workflow create --resource-group $resgrp --integration-service-environment $iseName --location $location --name $logicappname --definition $appTemplatePath --state $state
This gets us usage error: --integration-service-environment [KEY=VALUE ...]
Help?

You should use 'id= <Resource id>' as the parameter value for --integration-service-environment
The resource id is usually found in the portal.
Try the below snippet
#Your resource id will be in this format
$ise = 'id= /subscriptions/<SUB_ID>/resourceGroups/<RESOURCEgroup>/providers/Microsoft.Logic/integrationServiceEnvironments/<ISE_NAME>'
#your earlier command with modification of the ise value.
az logic workflow create --resource-group $resgrp --name $logicappname --definition $appTemplatePath --location $location --integration-service-environment $ise
Note :
Ensure,location of the logic app and ise are the same.

Related

Unable to parse parameter: promoteorqurantineFunctionName

I'm deploying an Azure function app as a part of security implementation into and I'm getting the above mentioned error as mentioned in Title section. Here is the powershell script i am running
az deployment group create
--name fss-promote-or-quarantine-plugin-deployment
--resource-group $RESOURCE_GROUP_NAME
--template-uri https://raw.githubusercontent.com/trendmicro/cloudone-filestorage
plugins/master/post-scan-actions/azure-python-promote-or-quarantine/template.json
-p promoteOrQuarantineFunctionName=$FUNCTION_NAME
scanningStorageAccountResourceID=$BLOB_STORAGE_ACCOUNT_RESOURCE_ID
scanResultTopicResourceID=$SCAN_RESULT_TOPIC_RESOURCE_ID
promoteStorageAccountConnectionString="$PROMOTE_STORAGE_ACCOUNT_CONNECTION_STRING"
promoteMode=move
quarantineStorageAccountConnectionString="$QUARANTINE_STORAGE_ACCOUNT_CONNECTION_STRING"
quarantineMode=move
Screenshot of the error that I'm getting:
I have tried by giving the space between the parameter names and values and it given the same error:
This cmdlet creates the storage account, taken from the GitHub ARM Article.
As #Mathias R. Jessen said, there should be no space between the parameter names and arguments passed in the CLI Cmdlets:

Fetch Azure API Management subscription key using azure cli

I am trying to get the subscription keys for my products as well as default subscription key using cli. I have gone through the documentation https://learn.microsoft.com/en-us/cli/azure/apim/api?view=azure-cli-latest , but right now I don't see any commands to get me the subscription key.
While I can see there are powershell way of getting it, we run the tasks in ubuntu pipeline, and the commands listed below is not working in the linux agent. It says Set-AzContext is not a known command
$subscriptionId = "id"
$RG = "rg"
$service = "apim-name"
Set-AzContext -Subscription $subscriptionId 
$apimContext = New-AzApiManagementContext -ResourceGroupName $RG -ServiceName $service
Get-AzApiManagementSubscriptionKey -Context $apimContext -SubscriptionId "master"
Update
I am able to fetch the details through powershell task for Azure in the DevOps pipeline. If there is no option in azure cli I will use this as a workaround.
Using az rest it is possible:
APIMID=`az apim show -n apimname -g resourcegroup --query id -o tsv`
az rest --method post --uri ${APIMID}/subscriptions/test-subscription/listSecrets?api-version=2021-08-01 --query primaryKey -o tsv
where test-subscription is the name of the subscription.
Currently it is not possible to fetch subscription key using AZ CLI commands. The PowerShell command used is the correct way to go. Just in case if it helps another way to get the subscription key is by using Management API call

Disable Azure function via AzureCLI does not disable function

I have a function app in Azure that has several functions defined. According to this document, I can use AzureCLI to disable a function in a function app. When I run az functionapp config appsettings set --name $functionAppName --resource-group $resourceGroupName --settings AzureWebJobs.myFunction.Disabled=true it creates the name value pair in application settings as stated in the documentation, but the state of the function does not toggle according to the value I set. Is something else required to toggle the state of the function when I run the AzureCLI commmand?
According to the comments, the problem was solved. OP change the azure function runtime from 1.x to 2.x and then it can be disabled by running this command.
az functionapp config appsettings set --name $functionAppName --resource-group $resourceGroupName --settings AzureWebJobs.myFunction.Disabled=true
Update1:
Update2:
For this problem, I confirmed with azure support team. They provided me with the response below:
They found the feature of az function app config part was released at Sep. 2018, and at that time runtime v1 was already quite out of date. So it is possible that the product team only develops for the runtime v2.
In a word, we can just do this operation on v2 and v3, or use Azure Portal UI.
For the guys who use the runtime 1.x but wanna enable/disable function by Azure CLI. According to the document, it shows:
So the workflow is:
Click APP Service Editor.
Comment out disabled field on function.json.
Run below command again.
az functionapp config appsettings set --name $functionAppName --resource-group $resourceGroupName --settings AzureWebJobs.myFunction.Disabled=true
This function will reference the app setting to determine it status.

What is the new AZ command to get logic app list using Powershell?

I can get we apps using the Az cmdlets by using az webapp list.
I have logic apps , I tried using az logicapp list
but its not recognised in Powershell.
Is there a manual listing the cmdlets to list logic apps ,sqlservers and sqldatabases ?
I wanted to provide an update to #4c74356b41's answer since it has been almost 3 years. For the Azure CLI there are now (as of at least June 2022) commands for managing Logic Apps, both of the "standard" and "consumption" varieties.
For "standard" Logic Apps you can manage them with the az logicapp command. E.g.:
az logicapp list --resource-group MyResourceGroup
For all the operations, run az logicapp --help.
For "consumption" Logic Apps, there is a (currently in preview) command of az logic workflow that requires a logic extension to be installed for the Azure CLI. E.g.:
az logic workflow list --resource-group MyResourceGroup
For all the operations, run az logic workflow --help.
#4c74356b41's answer is definitely still valid, but better support for managing Logic Apps is now a part of the Azure CLI (which is also not directly tied to PowerShell as indicated by the OP's question...the Azure CLI does not have to be run in PowerShell).
See Microsoft's official docs for these Azure CLI commands (and others) at:
Standard Logic Apps
Consumption Logic Apps
the AZ cli equivalent of Get-AzLogicApp is the following:
az resource list --resource-type 'Microsoft.Logic/workflows'
there are no dedicated cmdlets for managing logic apps in Az cli yet.
You could use below method to get logic app list.
Get-AzResource -ResourceType "Microsoft.Logic/workflows" -ResourceGroupName resourcegroupname
As for the sqlservers and sqldatabase, you could just use the method provided.
Get-AzSqlDatabase and Get-AzSqlServer support to list the servers and the databases.

Creating Azure function app against existing consumption plan

I have created a function app against a new consumption plan with the following command:
az functionapp create
--resource-group myresourcegroup
--storage-account mystorageaccount
--name myfunctionapp
--runtime node
--consumption-plan-location northeurope
This creates the function app correctly, but the app service plan is called NorthEuropePlan, which does not meet the naming guidelines I am following. I cannot see anything in the docs that will allow me to change this name.
Therefore, I would like to create the app service plan before, as a consumption plan (tier Y1 Dynamic), and then create a function app against this plan.
az resource create
--resource-group myresourcegroup
--name myconsumptionplan
--resource-type Microsoft.web/serverfarms
--is-full-object
--properties "{\"location\":\"northeurope\",\"sku\":{\"name\":\"Y1\",\"tier\":\"Dynamic\"}}"
That command works correctly, and creates me an app service plan. However, when I try to use that plan (substituting --consumption-plan-location northeurope for --plan myconsumptionplan), I get this error:
There was a conflict. AlwaysOn cannot be set for this site as the plan does not allow it.
Do I need to specify some more configuration when I make the app service plan?
When I run az appservice plan show against NorthEuropePlan and myconsumptionplan, the only difference in the object that comes back is the name.
When you are using --plan I believe the run time will think it is an App Service Plan and will configure Always ON which is not allowed in consumption plan so I guess you cannot do it like the way you are doing.
You can achieve it with ARM template though. Below is the example command:
az group create
--name ExampleGroup
--location "North Europe"
az group deployment create
--name ExampleDeployment
--resource-group ExampleGroup
--template-uri "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-function-app-create-dynamic/azuredeploy.json"
The URL mentioned in the template-uri is sample template which will create consumption-pan, storage and functionapp.
Deployment will ask the name of parameters (appName) at runtime.

Resources