GetToken function
26 Jul 2020Works with Azure PowerShell Az module
Before running the ‘GetToken’ you have to Sign in to Azure obviously using ‘Connect-AzAccount’ cmdlet.
Thanks for reading!
Works with Azure PowerShell Az module
Before running the ‘GetToken’ you have to Sign in to Azure obviously using ‘Connect-AzAccount’ cmdlet.
Thanks for reading!
In previous post I was complaining how I received a BadRequest error when trying to create or update host secret in Function App using ARM Api. But how I’m actually doing this?
One way is to use Postman and call ARM Api. I’m calling ARM Api using PowerShell Invoke-WebRequest cmdlet in my scripts and then using this in CI/CD to create/update/get/delete api keys on Function Apps in my Azure Tenant.
Actually I’m and following instructions in the docs:
And here’s is a part of my code. Also I’m describing [here](/2020/07/24/badrequest-error-function-app-create-or-update-host-secret/ why I’m building JSON body (variable $body) in this way for Create/Update request.
I’m using ‘GetToken’ function to acquire current session authentication token. Code for the function is here.
Thanks for reading!
When creating or updating host secret (aka ApiKey) for Function App using ARM Api, have you ever received a error message “Properties object is not present in the request body.”? Well I did.
Here’s full error response body I was receiving:
Message states, I’m sending incorrect body. So what I’m sending in the body? Just a simple JSON:
Let’s see in the docs: https://docs.microsoft.com/en-us/rest/api/appservice/webapps/createorupdatehostsecret#request-body.
According to thee docs, I should send just two parameters in the body “name” and “value”:
Name | Type | Description |
---|---|---|
name | string | Key name |
value | string | Key value |
Looks easy. But ARM Api keeps telling me something is missing. Not so easy, though. How should correct JSON look like then?
Correct JSON should look like so:
Thats it! Simple, isn’t it?
Bonus: how to create Function App Host Secret using PowerShell.
Thanks for reading!
Too many Azure Tenants under Switch Directory in Azure Portal?
Microsoft explained this in detail in the docs: https://docs.microsoft.com/en-us/azure/active-directory/b2b/leave-the-organization
Here’s a brief instruction copied from the docs.
Thanks for reading!
Pages 1 of 1