Generate the SAS key for the Azure IoT Central using PowerShell - azure

I tried the below code to generate the SAS key for the Azure IoT Central.
az iot central device compute-device-key --pk {primaryKey} --device-id {deviceid}
But it gives the below error.
Please let me know how to generate the SAS key for the Azure IoT Central using PowerShell

You need to update your azure-iot extension for Azure CLI. You might also need to update Azure CLI itself.
az extension update --name azure-iot
https://github.com/Azure/azure-iot-cli-extension#installation

Related

error while try to get connection strings for Azure Iot hub in Azure CLI

I want to get connecting string details, as per microsoft document i have run the below command in Azure CLI 2.0. unfortunately it throws below error. i have surfed much in google but i couldn't get apple answer. please can some one help me on this. thanks in advance.
My command :
az iot hub device-identity show-connection-string --device-id testDevice
Error:
az iot hub: 'device-identity' is not in the 'az iot hub' command group. See 'az iot hub --help'.
To use this command az iot hub device-identity show-connection-string --device-id testDevice you need install Microsoft Azure IoT Extension for Azure CLI.
You can install it using the following command:
az extension add --name azure-cli-iot-ext
More commands depend on Azure IoT extension are here.
For your issue, the answer just as the error saying there is no device-identity in az iot hub. If you want to get connection string, you can use az iot hub show-connection-string or az iot device show-connection-string

Add Application Insights to an azure function with Azure CLI

I have a PowerShell script which creates an azure function app on a consumption plan and its associated storage account within a resource group using the azure cli following the example In the Microsoft Docs
However to enable application insights I have to go to the azure portal, find the func select monitor and click enable application insights.
How can I expand that script to enable automate this step for the newly created function? I have been unable to find any specific documentation or examples and I would prefer to avoid resource templates if possible.
OF course, you could enable Application Insights to the azure function by Azure CLI.
But you need to create the Application Insights in the portal first, currently, it is unable to create Application Insights via Azure CLI.
You could follow the steps below.
1.Go to your Application Insights in the portal, copy the Instrumentation Key in the screenshot.
2.After creating the function app by your command , just use the CLI command below.
az functionapp config appsettings set --name <functionname> --resource-group <resourcegroupname> --settings 'APPINSIGHTS_INSTRUMENTATIONKEY = <Instrumentation Key>'
It works fine on my side, you could check it in the portal.

Azure : Problems while Creating X-509 certificate

I am trying to create a X 509 certificate and upload it to Azure Portal. However, after I followed the steps from this link, I am unable to VERIFY the certificate on the Azure Portal.
NOTE :
I have used the generated verification code from the Azure Portal for the registered certificate.
Azure Portal does NOT flash any error.
Mine is a FREE Trial Azure Account.
Can anyone help me in the following :
How do I trace Azure Portal Logs ? How can I track if I encountered any errors while uploading certificate.
What could have been a possible reason for this issue ?
Look forward to your help. Thanks !
This known issue has been fixed now.In addition, you can also use Azure CLI to work around for certificate verification.
Download the Azure CLI from here,and install it in your local PC;
Open powershell and run as administrator;
Execute the az login command to login with your Azure Account;
Upload the CA certificate file you have generated to IoT Hub through executing the following command:
az iot hub certificate create --hub-name <azure-iot-hub-name> --name <certificate name> --path <certificate file path>
Generate a verification code for the certificate using az iot hub certificate generate-verification-code. You can view the from Azure Portal:
az iot hub certificate generate-verification-code --hub-name <azure-iot-hub-name> --name <certificate name> --etag <ETag>
After executed successfully,you will get the response from Azure including the verificationCode, according with this code, generate the verification certificate file.
Verifies the certificate by using the following cmdlet. Please note that, int this step you need to reacquire the ETag because it has been refreshed in last step:
az iot hub certificate verify --hub-name <azure-iot-hub-name> --name <certificate name> --path <erification certificate file> --etag <ETag>
In the end, the certificate will be verified.In addition you can get more introductions about Azure CLI Command from here(https://learn.microsoft.com/en-us/cli/azure/iot/hub?view=azure-cli-latest).

Azure CLI create KEY for an app

I'm struggeling to find a way how one can add/create a key for the app in Azure AD using CLI?
What I mean by the key is authentication token with the expiry time under AD->App Name->Settings->Keys.
All of the documentation I have found so far is for adding everything but the key as if Microsoft again decided that it's better to CLICK like a monkey rather then use CLI or API.
Is this possible, can you create the key through CLI?
For a new Azure AD app, you could specify a key with Azure Cli 2.0. For example.
az ad app create --display-name "test" --homepage "http://localhost" --identifier-uris "https://localhost" --password "123adfaesdf"
You could use az ad app update to modify expiry time.
However, currently, Azure Cli does not support add a new key for an existing app. You also could refer to this similar question.

How to get connection string to existing servicebus without old azure portal

Due to restrictions in the company I cannot use old azure portal. But I have a requirement to use ServiceBus in our project. I was able to create servicebus ns using resource.azure.com, but I cannot find the way to get the connection string to that servicebus namespace.
I was trying to play around azure power shell, but it also requires access to old azure portal...
Thanks in advance.
Go to New Azure portal and get the Azure Service bus Connection string. Here I attached the image to follow up the instruction.
On the portal Go to your service bus queue, -> Shared access policies -> RootManageSharedAccessKey -> On the pane that opens on the right, copy the Primary Connection string.
You can do this via powershell with the Azure Powershell Cmdlets.
You can find the installer for them via How to install and configure Azure PowerShell - see the link under Installing Azure PowerShell from WebPI.
Once installed:
Add the account first
Add-AzureAccount
Enter your credentials to connect to your Azure account
Select the specific subscription that you want to work with
Select-AzureSubscription -SubscriptionName "Your_Sub_Name"
List your Service Bus namespaces
Get-AzureSBNamespace
All your namespaces, along with the connection string (for RootManageSharedAccessKey) will be listed.
(Optional) If you have specific shared access key names that you've created, you can get them like this:
Get-AzureSBAuthorizationRule -Namespace your_namespace
The namespace will be the name listed in the output from step 3
For those using Azure CLI this will do
az servicebus namespace authorization-rule keys list \
-g "<group>" \
--namespace-name "<namespace>" \
-n "RootManageSharedAccessKey" \
--query "primaryConnectionString" -o tsv

Resources