# Custom python extension - migration from v1 to v2

**URL:** <https://community.dynatrace.com/t/custom-python-extension-migration-from-v1-to-v2/47638>\
**Category:** Extensions\
**Tags:** migration, python, extensions\
**Created:** [September 13, 2024, 7:22am UTC](https://community.dynatrace.com/t/custom-python-extension-migration-from-v1-to-v2/47638 "2024-09-13T07:22:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jannick\_deturck](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/jannick_deturck/32/26735_2.png) [@jannick\_deturck](https://community.dynatrace.com/u/jannick_deturck)\
**Post date:** [September 13, 2024, 7:22am UTC](https://community.dynatrace.com/t/custom-python-extension-migration-from-v1-to-v2/47638/1 "2024-09-13T07:22:06Z")

</div>

In my v1 python extension I have a definition “initialize” that only will be executed during a first run, also referencing to a HealthcheckHost.json file

def initialize(self, \*\*kwargs):

#will only be executed during the first run.&nbsp; &nbsp; &nbsp; &nbsp; #capture parameters and save them in memmory&nbsp; &nbsp; &nbsp; &nbsp; script\_dir = os.path.dirname(\_\_file\_\_)&nbsp; &nbsp; &nbsp; &nbsp; file\_path = os.path.join(script\_dir, “HealthcheckHosts.json”)  
&nbsp; &nbsp; &nbsp; &nbsp; #read in parameters&nbsp; &nbsp; &nbsp; &nbsp; self.url = self.config[“url”]&nbsp; &nbsp; &nbsp; &nbsp; self.hostpattern = self.config[“hosts”]&nbsp; &nbsp; &nbsp; &nbsp; self.disableAlertBool = self.config[“disableAllerting”]&nbsp; &nbsp; &nbsp; &nbsp; self.httpmethod = self.config[“httpmethod”]&nbsp; &nbsp; &nbsp; &nbsp; self.rqmethod = self.config[“requestmethod”]&nbsp; &nbsp; &nbsp; &nbsp; self.port = 9000 &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; self.applicationcheckname = self.config[“app”]&nbsp; &nbsp; &nbsp; &nbsp; splits = self.url.split(‘/’)&nbsp; &nbsp; &nbsp; &nbsp; self.appextentionname = splits[1]&nbsp; &nbsp; &nbsp; &nbsp; self.warningSend = False…Can somebody explain me where I need to put this definition in the new extension v2 structure???

 ![jannick_deturck_0-1726212028274.png](https://global.discourse-cdn.com/dynatrace/original/3X/3/9/39036ef077aef0adde12398d884d25fbf02f8770.png)

cfr:&nbsp;[Extension Structure — dt-sdk 1.0.0 documentation (dynatrace-extensions.github.io)](https://dynatrace-extensions.github.io/dt-extensions-python-sdk/guides/extension_structure.html)

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [September 14, 2024, 9:20am UTC](https://community.dynatrace.com/t/custom-python-extension-migration-from-v1-to-v2/47638/2 "2024-09-14T09:20:23Z")

</div>

That goes into the def initialize(self) function. If you use our vscode addon or the sdk to generate your project, it should automatically have that function as part of the template.
