Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions to list keys of Function Apps #297

Merged
merged 8 commits into from
Jul 10, 2019

Conversation

mikhailshilkov
Copy link
Member

Adds mixin functions to wrap ARM API calls to List Keys of Function Apps, as described in this issue.

Required for #295 or in case we want to support non-anonymous HTTP callback functions.

A function getServiceClientCredentials got introduced in core package. It might be useful for any REST interaction with the Azure Management API.

I enabled "format on save" in my VS Code, so some old lines got re-formated. Let me know if that's too annoying.

@mikhailshilkov
Copy link
Member Author

mikhailshilkov commented Jul 8, 2019

Note that we might get this from Terraform at some point, but they are blocked upstream, so probably not in short-term. See hashicorp/terraform-provider-azurerm#699

};

FunctionApp.prototype.getFunctionKeys = function(this: FunctionApp, functionName) {
return pulumi.all([this.id, functionName]).apply(async ([id, name]) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm feeling dumb, but i cannot understand what this functionName is for. is it just to ensure that hte function has been created first before getFunctionKeys has been called? it seems weird...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its used below in line 773 in the API call to the ARM Api to identify the function inside of the function app.

Copy link
Member Author

@mikhailshilkov mikhailshilkov Jul 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each function has its own set of keys in addition to the host keys, so the request URL contains the name as @ChristianEder kindly noticed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh... doh. I see now. i was looking for functionName, and not 'name'. In general we actually like reusing the names (i.e. pulumi.all([this.id, functionName]).apply(async ([id, functionName]). It helps indicate they represent the same thing, and it makes sure that the outer variable is blocked from being used in the inner scope. I was looking for that pattern and that's what threw me off. This is all good, thanks for clarifying!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, I'll rename and pick up this pattern.

@CyrusNajmabadi
Copy link
Contributor

Done with review pass. LGTM, but i did hav ea question about something odd...

@mikhailshilkov mikhailshilkov merged commit a00afef into master Jul 10, 2019
@pulumi-bot pulumi-bot deleted the mikhailshilkov/list-function-keys branch July 10, 2019 06:43
} else {
// `create()` will throw an error if the Az CLI is not installed or `az login` has never been run.
credentials = await msnodeauth.AzureCliCredentials.create();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure these are the complete set of configuration options supported by the Azure provider? I'm a little nervous re-creating this logic outside of the provider. Could we perhaps cross-reference to the primary source for this logic? (Ideally in the backing provider to make sure it's really the same as what the user is seeing for other @pulumi/azure operations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, me too... I don't know of the source of truth for this.
Ideally, I'd use some function provided by Pulumi core/Terraform which would give me an access token that the provider is already using. Is there something like that? I asked on Slack once but didn't get an answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants